home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / vir_real / veos / part16 < prev   
Encoding:
Internet Message Format  |  1993-06-20  |  91.9 KB

  1. Path: wupost!uunet!decwrl!vixie!vixie!not-for-mail
  2. From: voodoo@hitl.washington.edu (Geoffery Coco)
  3. Newsgroups: comp.sources.unix
  4. Subject: v26i199: veos-2.0 - The Virtual Environment Operating Shell, V2.0, Part16/16
  5. Date: 25 Apr 1993 23:15:46 -0700
  6. Organization: Vixie Home Computing
  7. Lines: 3534
  8. Sender: vixie@vix.com
  9. Approved: paul@vix.com
  10. Message-ID: <1rfumi$5oh@efficacy.home.vix.com>
  11. NNTP-Posting-Host: efficacy.home.vix.com
  12.  
  13. Submitted-By: voodoo@hitl.washington.edu (Geoffery Coco)
  14. Posting-Number: Volume 26, Issue 199
  15. Archive-Name: veos-2.0/part16
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 16 (of 16)."
  24. # Contents:  docs/xlisp.doc
  25. # Wrapped by vixie@efficacy.home.vix.com on Sun Apr 25 23:10:47 1993
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'docs/xlisp.doc' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'docs/xlisp.doc'\"
  29. else
  30. echo shar: Extracting \"'docs/xlisp.doc'\" \(88634 characters\)
  31. sed "s/^X//" >'docs/xlisp.doc' <<'END_OF_FILE'
  32. X
  33. X
  34. X
  35. X
  36. X
  37. X
  38. X                         XLISP: An Object-oriented Lisp
  39. X
  40. X                             Version 2.1 (WINTERP)
  41. X
  42. X                                 April 23, 1989
  43. X
  44. X
  45. X                                       by
  46. X                               David Michael Betz
  47. X                                  P.O. Box 144
  48. X                             Peterborough, NH 03458
  49. X
  50. X                             (603) 924-4145 (home)
  51. X
  52. X                   Copyright (c) 1989, by David Michael Betz
  53. X
  54. X
  55. X
  56. X    Note: This document has been updated to include new lisp primitives
  57. X          added by the WINTERP distribution of XLISP 2.1.
  58. X
  59. X    WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  60. X
  61. X    $Header: xlisp.doc,v 1.6 90/07/03 20:51:57 mayer Exp $
  62. X
  63. X
  64. X
  65. X
  66. X
  67. X
  68. X
  69. X
  70. X
  71. X
  72. X
  73. X
  74. X
  75. X
  76. X
  77. X
  78. X
  79. X
  80. X
  81. X
  82. X
  83. X
  84. X
  85. X
  86. X
  87. X
  88. X
  89. X
  90. X
  91. X
  92. X
  93. X
  94. X
  95. X
  96. X
  97. X
  98. X
  99. X
  100. X
  101. X        XLISP                  TABLE OF CONTENTS                  Page 2
  102. X
  103. X
  104. X                               Table of Contents
  105. X
  106. X
  107. X                TABLE OF CONTENTS                        2
  108. X
  109. X                INTRODUCTION                             4
  110. X
  111. X                A NOTE FROM THE AUTHOR                   5
  112. X
  113. X                XLISP COMMAND LOOP                       6
  114. X
  115. X                BREAK COMMAND LOOP                       7
  116. X
  117. X                DATA TYPES                               8
  118. X
  119. X                THE EVALUATOR                            9
  120. X
  121. X                LEXICAL CONVENTIONS                     10
  122. X
  123. X                READTABLES                              11
  124. X
  125. X                LAMBDA LISTS                            12
  126. X
  127. X                OBJECTS                                 14
  128. X
  129. X                SYMBOLS                                 17
  130. X
  131. X                EVALUATION FUNCTIONS                    18
  132. X
  133. X                SYMBOL FUNCTIONS                        19
  134. X
  135. X                PROPERTY LIST FUNCTIONS                 21
  136. X
  137. X                ARRAY FUNCTIONS                         22
  138. X
  139. X                LIST FUNCTIONS                          23
  140. X
  141. X                DESTRUCTIVE LIST FUNCTIONS              26
  142. X
  143. X                PREDICATE FUNCTIONS                     27
  144. X
  145. X                CONTROL CONSTRUCTS                      29
  146. X
  147. X                LOOPING CONSTRUCTS                      31
  148. X
  149. X                THE PROGRAM FEATURE                     32
  150. X
  151. X                DEBUGGING AND ERROR HANDLING            33
  152. X
  153. X                ARITHMETIC FUNCTIONS                    34
  154. X
  155. X                BITWISE LOGICAL FUNCTIONS               36
  156. X
  157. X                STRING FUNCTIONS                        37
  158. X
  159. X
  160. X
  161. X
  162. X
  163. X
  164. X
  165. X
  166. X
  167. X        XLISP                  TABLE OF CONTENTS                  Page 3
  168. X
  169. X
  170. X                CHARACTER FUNCTIONS                     39
  171. X
  172. X                INPUT/OUTPUT FUNCTIONS                  41
  173. X
  174. X                THE FORMAT FUNCTION                     42
  175. X
  176. X                FILE I/O FUNCTIONS                      43
  177. X
  178. X                STRING STREAM FUNCTIONS                 44
  179. X
  180. X                STRUCTURES                              45
  181. X
  182. X                SYSTEM FUNCTIONS                        46
  183. X
  184. X                EXAMPLES                                48
  185. X
  186. X        UN*X-SPECIFIC FUNCTIONS (FOR WINTERP)   52
  187. X
  188. X
  189. X
  190. X
  191. X
  192. X
  193. X
  194. X
  195. X
  196. X
  197. X
  198. X
  199. X
  200. X
  201. X
  202. X
  203. X
  204. X
  205. X
  206. X
  207. X
  208. X
  209. X
  210. X
  211. X
  212. X
  213. X
  214. X
  215. X
  216. X
  217. X
  218. X
  219. X
  220. X
  221. X
  222. X
  223. X
  224. X
  225. X
  226. X
  227. X
  228. X
  229. X
  230. X
  231. X
  232. X
  233. X        XLISP                     INTRODUCTION                    Page 4
  234. X
  235. X
  236. X        INTRODUCTION
  237. X
  238. X        XLISP is an experimental programming language combining some of
  239. X        the features of Common Lisp with an object-oriented extension
  240. X        capability.  It was implemented to allow experimentation with
  241. X        object-oriented programming on small computers.
  242. X
  243. X        There are currently implementations of XLISP running on the IBM-
  244. X        PC and clones under MS-DOS, on the Macintosh, the Atari-ST and
  245. X        the Amiga.  It is completely written in the programming language
  246. X        'C' and is easily extended with user written built-in functions
  247. X        and classes.  It is available in source form to non-commercial
  248. X        users.
  249. X
  250. X        Many Common Lisp functions are built into XLISP.  In addition,
  251. X        XLISP defines the objects 'Object' and 'Class' as primitives.
  252. X        'Object' is the only class that has no superclass and hence is
  253. X        the root of the class heirarchy tree.  'Class' is the class of
  254. X        which all classes are instances (it is the only object that is
  255. X        an instance of itself).
  256. X
  257. X        This document is a brief description of XLISP.  It assumes some
  258. X        knowledge of LISP and some understanding of the concepts of
  259. X        object-oriented programming.
  260. X
  261. X        I recommend the book "LISP" by Winston and Horn and published by
  262. X        Addison Wesley for learning Lisp.  The first edition of this
  263. X        book is based on MacLisp and the second edition is based on
  264. X        Common Lisp.  XLISP will continue to migrate towards
  265. X        compatibility with Common Lisp.
  266. X
  267. X        You will probably also need a copy of "Common Lisp: The
  268. X        Language" by Guy L. Steele, Jr., published by Digital Press to
  269. X        use as a reference for some of the Common Lisp functions that
  270. X        are described only briefly in this document.
  271. X
  272. X
  273. X
  274. X
  275. X
  276. X
  277. X
  278. X
  279. X
  280. X
  281. X
  282. X
  283. X
  284. X
  285. X
  286. X
  287. X
  288. X
  289. X
  290. X
  291. X
  292. X
  293. X
  294. X
  295. X
  296. X
  297. X
  298. X
  299. X        XLISP                A NOTE FROM THE AUTHOR               Page 5
  300. X
  301. X
  302. X        A NOTE FROM THE AUTHOR
  303. X
  304. X        If you have any problems with XLISP, feel free to contact me for
  305. X        help or advice.  Please remember that since XLISP is available
  306. X        in source form in a high level language, many users have been
  307. X        making versions available on a variety of machines.  If you call
  308. X        to report a problem with a specific version, I may not be able
  309. X        to help you if that version runs on a machine to which I don't
  310. X        have access.  Please have the version number of the version that
  311. X        you are running readily accessible before calling me.
  312. X
  313. X        If you find a bug in XLISP, first try to fix the bug yourself
  314. X        using the source code provided.  If you are successful in fixing
  315. X        the bug, send the bug report along with the fix to me.  If you
  316. X        don't have access to a C compiler or are unable to fix a bug,
  317. X        please send the bug report to me and I'll try to fix it.
  318. X
  319. X        Any suggestions for improvements will be welcomed.  Feel free to
  320. X        extend the language in whatever way suits your needs.  However,
  321. X        PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
  322. X        FIRST!!  I would like to be the clearing house for new features
  323. X        added to XLISP.  If you want to add features for your own
  324. X        personal use, go ahead.  But, if you want to distribute your
  325. X        enhanced version, contact me first.  Please remember that the
  326. X        goal of XLISP is to provide a language to learn and experiment
  327. X        with LISP and object-oriented programming on small computers.  I
  328. X        don't want it to get so big that it requires megabytes of memory
  329. X        to run.
  330. X
  331. X
  332. X
  333. X
  334. X
  335. X
  336. X
  337. X
  338. X
  339. X
  340. X
  341. X
  342. X
  343. X
  344. X
  345. X
  346. X
  347. X
  348. X
  349. X
  350. X
  351. X
  352. X
  353. X
  354. X
  355. X
  356. X
  357. X
  358. X
  359. X
  360. X
  361. X
  362. X
  363. X
  364. X
  365. X        XLISP                 XLISP COMMAND LOOP                  Page 6
  366. X
  367. X
  368. X        XLISP COMMAND LOOP
  369. X
  370. X        When XLISP is started, it first tries to load the workspace
  371. X        "xlisp.wks" from the current directory.  If that file doesn't
  372. X        exist, XLISP builds an initial workspace, empty except for the
  373. X        built-in functions and symbols.
  374. X
  375. X        Then XLISP attempts to load "init.lsp" from the current
  376. X        directory.  It then loads any files named as parameters on the
  377. X        command line (after appending ".lsp" to their names).
  378. X
  379. X        XLISP then issues the following prompt:
  380. X
  381. X        >
  382. X
  383. X        This indicates that XLISP is waiting for an expression to be
  384. X        typed.
  385. X
  386. X        When a complete expression has been entered, XLISP attempts to
  387. X        evaluate that expression.  If the expression evaluates
  388. X        successfully, XLISP prints the result and then returns to the
  389. X        initial prompt waiting for another expression to be typed.
  390. X
  391. X
  392. X
  393. X
  394. X
  395. X
  396. X
  397. X
  398. X
  399. X
  400. X
  401. X
  402. X
  403. X
  404. X
  405. X
  406. X
  407. X
  408. X
  409. X
  410. X
  411. X
  412. X
  413. X
  414. X
  415. X
  416. X
  417. X
  418. X
  419. X
  420. X
  421. X
  422. X
  423. X
  424. X
  425. X
  426. X
  427. X
  428. X
  429. X
  430. X
  431. X        XLISP                 BREAK COMMAND LOOP                  Page 7
  432. X
  433. X
  434. X        BREAK COMMAND LOOP
  435. X
  436. X        When XLISP encounters an error while evaluating an expression,
  437. X        it attempts to handle the error in the following way:
  438. X
  439. X        If the symbol '*breakenable*' is true, the message corresponding
  440. X        to the error is printed.  If the error is correctable, the
  441. X        correction message is printed.
  442. X
  443. X        If the symbol '*tracenable*' is true, a trace back is printed.
  444. X        The number of entries printed depends on the value of the symbol
  445. X        '*tracelimit*'.  If this symbol is set to something other than a
  446. X        number, the entire trace back stack is printed.
  447. X
  448. X        XLISP then enters a read/eval/print loop to allow the user to
  449. X        examine the state of the interpreter in the context of the
  450. X        error.  This loop differs from the normal top-level
  451. X        read/eval/print loop in that if the user invokes the function
  452. X        'continue', XLISP will continue from a correctable error.  If
  453. X        the user invokes the function 'clean-up', XLISP will abort the
  454. X        break loop and return to the top level or the next lower
  455. X        numbered break loop.  When in a break loop, XLISP prefixes the
  456. X        break level to the normal prompt.
  457. X
  458. X        If the symbol '*breakenable*' is nil, XLISP looks for a
  459. X        surrounding errset function.  If one is found, XLISP examines
  460. X        the value of the print flag.  If this flag is true, the error
  461. X        message is printed.  In any case, XLISP causes the errset
  462. X        function call to return nil.
  463. X
  464. X        If there is no surrounding errset function, XLISP prints the
  465. X        error message and returns to the top level.
  466. X
  467. X
  468. X
  469. X
  470. X
  471. X
  472. X
  473. X
  474. X
  475. X
  476. X
  477. X
  478. X
  479. X
  480. X
  481. X
  482. X
  483. X
  484. X
  485. X
  486. X
  487. X
  488. X
  489. X
  490. X
  491. X
  492. X
  493. X
  494. X
  495. X
  496. X
  497. X        XLISP                      DATA TYPES                     Page 8
  498. X
  499. X
  500. X        DATA TYPES
  501. X
  502. X        There are several different data types available to XLISP
  503. X        programmers.
  504. X
  505. X            o lists
  506. X            o symbols
  507. X            o strings
  508. X            o integers
  509. X            o characters
  510. X            o floats
  511. X            o objects
  512. X            o arrays
  513. X            o streams
  514. X            o subrs (built-in functions)
  515. X            o fsubrs (special forms)
  516. X            o closures (user defined functions)
  517. X
  518. X
  519. X
  520. X
  521. X
  522. X
  523. X
  524. X
  525. X
  526. X
  527. X
  528. X
  529. X
  530. X
  531. X
  532. X
  533. X
  534. X
  535. X
  536. X
  537. X
  538. X
  539. X
  540. X
  541. X
  542. X
  543. X
  544. X
  545. X
  546. X
  547. X
  548. X
  549. X
  550. X
  551. X
  552. X
  553. X
  554. X
  555. X
  556. X
  557. X
  558. X
  559. X
  560. X
  561. X
  562. X
  563. X        XLISP                    THE EVALUATOR                    Page 9
  564. X
  565. X
  566. X        THE EVALUATOR
  567. X
  568. X        The process of evaluation in XLISP:
  569. X
  570. X        Strings, integers, characters, floats, objects, arrays, streams,
  571. X        subrs, fsubrs and closures evaluate to themselves.
  572. X
  573. X        Symbols act as variables and are evaluated by retrieving the
  574. X        value associated with their current binding.
  575. X
  576. X        Lists are evaluated by examining the first element of the list
  577. X        and then taking one of the following actions:
  578. X
  579. X            If it is a symbol, the functional binding of the symbol is
  580. X            retrieved.
  581. X
  582. X            If it is a lambda expression, a closure is constructed for
  583. X            the function described by the lambda expression.
  584. X
  585. X            If it is a subr, fsubr or closure, it stands for itself.
  586. X
  587. X            Any other value is an error.
  588. X
  589. X        Then, the value produced by the previous step is examined:
  590. X
  591. X            If it is a subr or closure, the remaining list elements are
  592. X            evaluated and the subr or closure is called with these
  593. X            evaluated expressions as arguments.
  594. X
  595. X            If it is an fsubr, the fsubr is called using the remaining
  596. X            list elements as arguments (unevaluated).
  597. X
  598. X            If it is a macro, the macro is expanded using the remaining
  599. X            list elements as arguments (unevaluated).  The macro
  600. X            expansion is then evaluated in place of the original macro
  601. X            call.
  602. X
  603. X
  604. X
  605. X
  606. X
  607. X
  608. X
  609. X
  610. X
  611. X
  612. X
  613. X
  614. X
  615. X
  616. X
  617. X
  618. X
  619. X
  620. X
  621. X
  622. X
  623. X
  624. X
  625. X
  626. X
  627. X
  628. X
  629. X        XLISP                 LEXICAL CONVENTIONS                Page 10
  630. X
  631. X
  632. X        LEXICAL CONVENTIONS
  633. X
  634. X        The following conventions must be followed when entering XLISP
  635. X        programs:
  636. X
  637. X        Comments in XLISP code begin with a semi-colon character and
  638. X        continue to the end of the line.
  639. X
  640. X        Symbol names in XLISP can consist of any sequence of non-blank
  641. X        printable characters except the following:
  642. X
  643. X                ( ) ' ` , " ;
  644. X
  645. X        Uppercase and lowercase characters are not distinguished within
  646. X        symbol names.  All lowercase characters are mapped to uppercase
  647. X        on input.
  648. X
  649. X        Integer literals consist of a sequence of digits optionally
  650. X        beginning with a '+' or '-'.  The range of values an integer can
  651. X        represent is limited by the size of a C 'long' on the machine on
  652. X        which XLISP is running.
  653. X
  654. X        Floating point literals consist of a sequence of digits
  655. X        optionally beginning with a '+' or '-' and including an embedded
  656. X        decimal point.  The range of values a floating point number can
  657. X        represent is limited by the size of a C 'float' ('double' on
  658. X        machines with 32 bit addresses) on the machine on which XLISP is
  659. X        running.
  660. X
  661. X        Literal strings are sequences of characters surrounded by double
  662. X        quotes.  Within quoted strings the '\' character is used to
  663. X        allow non-printable characters to be included.  The codes
  664. X        recognized are:
  665. X
  666. X                \\        means the character '\'
  667. X                \n       means newline
  668. X                \t       means tab
  669. X                \r       means return
  670. X                \f       means form feed
  671. X                \nnn     means the character whose octal code is nnn
  672. X
  673. X
  674. X
  675. X
  676. X
  677. X
  678. X
  679. X
  680. X
  681. X
  682. X
  683. X
  684. X
  685. X
  686. X
  687. X
  688. X
  689. X
  690. X
  691. X
  692. X
  693. X
  694. X
  695. X        XLISP                      READTABLES                    Page 11
  696. X
  697. X
  698. X        READTABLES
  699. X
  700. X        The behaviour of the reader is controlled by a data structure
  701. X        called a "readtable".  The reader uses the symbol *READTABLE* to
  702. X        locate the current readtable.  This table controls the
  703. X        interpretation of input characters.  It is an array with 128
  704. X        entries, one for each of the ASCII character codes.  Each entry
  705. X        contains one of the following things:
  706. X
  707. X                NIL             Indicating an invalid character
  708. X                :CONSTITUENT    Indicating a symbol constituent
  709. X                :WHITE-SPACE    Indicating a whitespace character
  710. X                (:TMACRO . fun) Terminating readmacro
  711. X                (:NMACRO . fun) Non-terminating readmacro
  712. X                :SESCAPE        Single escape character ('\')
  713. X                :MESCAPE        Multiple escape character ('|')
  714. X
  715. X        In the case of :TMACRO and :NMACRO, the "fun" component is a
  716. X        function.  This can either be a built-in readmacro function or a
  717. X        lambda expression.  The function should take two parameters.
  718. X        The first is the input stream and the second is the character
  719. X        that caused the invocation of the readmacro.  The readmacro
  720. X        function should return NIL to indicate that the character should
  721. X        be treated as white space or a value consed with NIL to indicate
  722. X        that the readmacro should be treated as an occurance of the
  723. X        specified value.  Of course, the readmacro code is free to read
  724. X        additional characters from the input stream.
  725. X
  726. X        XLISP defines several useful read macros:
  727. X
  728. X                '<expr>         == (quote <expr>)
  729. X                #'<expr>        == (function <expr>)
  730. X                #(<expr>...)    == an array of the specified expressions
  731. X                #x<hdigits>     == a hexadecimal number (0-9,A-F)
  732. X                #o<odigits>     == an octal number (0-7)
  733. X                #b<bdigits>     == a binary number (0-1)
  734. X                #\<char> == the ASCII code of the character
  735. X                #| ... |#       == a comment
  736. X                #:<symbol>      == an uninterned symbol
  737. X                `<expr>         == (backquote <expr>)
  738. X                ,<expr>         == (comma <expr>)
  739. X                ,@<expr>        == (comma-at <expr>)
  740. X
  741. X
  742. X
  743. X
  744. X
  745. X
  746. X
  747. X
  748. X
  749. X
  750. X
  751. X
  752. X
  753. X
  754. X
  755. X
  756. X
  757. X
  758. X
  759. X
  760. X
  761. X        XLISP                     LAMBDA LISTS                   Page 12
  762. X
  763. X
  764. X        LAMBDA LISTS
  765. X
  766. X        There are several forms in XLISP that require that a "lambda
  767. X        list" be specified.  A lambda list is a definition of the
  768. X        arguments accepted by a function.  There are four different
  769. X        types of arguments.
  770. X
  771. X        The lambda list starts with required arguments.  Required
  772. X        arguments must be specified in every call to the function.
  773. X
  774. X        The required arguments are followed by the &optional arguments.
  775. X        Optional arguments may be provided or omitted in a call.  An
  776. X        initialization expression may be specified to provide a default
  777. X        value for an &optional argument if it is omitted from a call.
  778. X        If no initialization expression is specified, an omitted
  779. X        argument is initialized to NIL.  It is also possible to provide
  780. X        the name of a 'supplied-p' variable that can be used to
  781. X        determine if a call provided a value for the argument or if the
  782. X        initialization expression was used.  If specified, the supplied-
  783. X        p variable will be bound to T if a value was specified in the
  784. X        call and NIL if the default value was used.
  785. X
  786. X        The &optional arguments are followed by the &rest argument.  The
  787. X        &rest argument gets bound to the remainder of the argument list
  788. X        after the required and &optional arguments have been removed.
  789. X
  790. X        The &rest argument is followed by the &key arguments.  When a
  791. X        keyword argument is passed to a function, a pair of values
  792. X        appears in the argument list.  The first expression in the pair
  793. X        should evaluate to a keyword symbol (a symbol that begins with a
  794. X        ':').  The value of the second expression is the value of the
  795. X        keyword argument.  Like &optional arguments, &key arguments can
  796. X        have initialization expressions and supplied-p variables.  In
  797. X        addition, it is possible to specify the keyword to be used in a
  798. X        function call.  If no keyword is specified, the keyword obtained
  799. X        by adding a ':' to the beginning of the keyword argument symbol
  800. X        is used.  In other words, if the keyword argument symbol is
  801. X        'foo', the keyword will be ':foo'.
  802. X
  803. X        The &key arguments are followed by the &aux variables.  These
  804. X        are local variables that are bound during the evaluation of the
  805. X        function body.  It is possible to have initialization
  806. X        expressions for the &aux variables.
  807. X
  808. X
  809. X
  810. X
  811. X
  812. X
  813. X
  814. X
  815. X
  816. X
  817. X
  818. X
  819. X
  820. X
  821. X
  822. X
  823. X
  824. X
  825. X
  826. X
  827. X        XLISP                     LAMBDA LISTS                   Page 13
  828. X
  829. X
  830. X        Here is the complete syntax for lambda lists:
  831. X
  832. X                (<rarg>...
  833. X                 [&optional [<oarg> | (<oarg> [<init> [<svar>]])]...]
  834. X                 [&rest <rarg>]
  835. X                 [&key
  836. X                   [<karg> | ([<karg> | (<key> <karg>)] [<init> [<svar>]])]...
  837. X                   &allow-other-keys]
  838. X                 [&aux
  839. X                   [<aux> | (<aux> [<init>])]...])
  840. X
  841. X            where:
  842. X
  843. X                <rarg>  is a required argument symbol
  844. X                <oarg>  is an &optional argument symbol
  845. X                <rarg>  is the &rest argument symbol
  846. X                <karg>  is a &key argument symbol
  847. X                <key>   is a keyword symbol
  848. X                <aux>   is an auxiliary variable symbol
  849. X                <init>  is an initialization expression
  850. X                <svar>  is a supplied-p variable symbol
  851. X
  852. X
  853. X
  854. X
  855. X
  856. X
  857. X
  858. X
  859. X
  860. X
  861. X
  862. X
  863. X
  864. X
  865. X
  866. X
  867. X
  868. X
  869. X
  870. X
  871. X
  872. X
  873. X
  874. X
  875. X
  876. X
  877. X
  878. X
  879. X
  880. X
  881. X
  882. X
  883. X
  884. X
  885. X
  886. X
  887. X
  888. X
  889. X
  890. X
  891. X
  892. X
  893. X        XLISP                       OBJECTS                      Page 14
  894. X
  895. X
  896. X        OBJECTS
  897. X
  898. X        Definitions:
  899. X
  900. X            o selector - a symbol used to select an appropriate method
  901. X            o message - a selector and a list of actual arguments
  902. X            o method - the code that implements a message
  903. X
  904. X        Since XLISP was created to provide a simple basis for
  905. X        experimenting with object-oriented programming, one of the
  906. X        primitive data types included is 'object'.  In XLISP, an object
  907. X        consists of a data structure containing a pointer to the
  908. X        object's class as well as an array containing the values of the
  909. X        object's instance variables.
  910. X
  911. X        Officially, there is no way to see inside an object (look at the
  912. X        values of its instance variables).  The only way to communicate
  913. X        with an object is by sending it a message.
  914. X
  915. X        You can send a message to an object using the 'send' function.
  916. X        This function takes the object as its first argument, the
  917. X        message selector as its second argument (which must be a symbol)
  918. X        and the message arguments as its remaining arguments.
  919. X
  920. X        The 'send' function determines the class of the receiving object
  921. X        and attempts to find a method corresponding to the message
  922. X        selector in the set of messages defined for that class.  If the
  923. X        message is not found in the object's class and the class has a
  924. X        super-class, the search continues by looking at the messages
  925. X        defined for the super-class.  This process continues from one
  926. X        super-class to the next until a method for the message is found.
  927. X        If no method is found, an error occurs.
  928. X
  929. X        A message can also be sent from the body of a method by using
  930. X        the current object, but the method lookup starts with the
  931. X        object's superclass rather than its class.  This allows a
  932. X        subclass to invoke a standard method in its parent class even
  933. X        though it overrides that method with its own specialized
  934. X        version.
  935. X
  936. X        When a method is found, the evaluator binds the receiving object
  937. X        to the symbol 'self' and evaluates the method using the
  938. X        remaining elements of the original list as arguments to the
  939. X        method.  These arguments are always evaluated prior to being
  940. X        bound to their corresponding formal arguments.  The result of
  941. X        evaluating the method becomes the result of the expression.
  942. X
  943. X
  944. X
  945. X
  946. X
  947. X
  948. X
  949. X
  950. X
  951. X
  952. X
  953. X
  954. X
  955. X
  956. X
  957. X
  958. X
  959. X        XLISP                       OBJECTS                      Page 15
  960. X
  961. X
  962. X        THE 'Object' CLASS
  963. X
  964. X        Classes:
  965. X
  966. X        Object  THE TOP OF THE CLASS HEIRARCHY
  967. X
  968. X            Messages:
  969. X
  970. X                :show  SHOW AN OBJECT'S INSTANCE VARIABLES
  971. X                    returns     the object
  972. X
  973. X                :class  RETURN THE CLASS OF AN OBJECT
  974. X                    returns     the class of the object
  975. X
  976. X                :isnew  THE DEFAULT OBJECT INITIALIZATION ROUTINE
  977. X                    returns     the object
  978. X
  979. X
  980. X
  981. X
  982. X
  983. X
  984. X
  985. X
  986. X
  987. X
  988. X
  989. X
  990. X
  991. X
  992. X
  993. X
  994. X
  995. X
  996. X
  997. X
  998. X
  999. X
  1000. X
  1001. X
  1002. X
  1003. X
  1004. X
  1005. X
  1006. X
  1007. X
  1008. X
  1009. X
  1010. X
  1011. X
  1012. X
  1013. X
  1014. X
  1015. X
  1016. X
  1017. X
  1018. X
  1019. X
  1020. X
  1021. X
  1022. X
  1023. X
  1024. X
  1025. X        XLISP                       OBJECTS                      Page 16
  1026. X
  1027. X
  1028. X        THE 'Class' CLASS
  1029. X
  1030. X        Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  1031. X
  1032. X            Messages:
  1033. X
  1034. X                :new  CREATE A NEW INSTANCE OF A CLASS
  1035. X                    returns     the new class object
  1036. X
  1037. X                :isnew <ivars> [<cvars> [<super>]]  INITIALIZE A NEW CLASS
  1038. X                    <ivars>     the list of instance variable symbols
  1039. X                    <cvars>     the list of class variable symbols
  1040. X                    <super>     the superclass (default is Object)
  1041. X                    returns     the new class object
  1042. X
  1043. X                :answer <msg> <fargs> <code>  ADD A MESSAGE TO A CLASS
  1044. X                    <msg>       the message symbol
  1045. X                    <fargs>     the formal argument list (lambda list)
  1046. X                    <code>      a list of executable expressions
  1047. X                    returns     the object
  1048. X
  1049. X
  1050. X        When a new instance of a class is created by sending the message
  1051. X        ':new' to an existing class, the message ':isnew' followed by
  1052. X        whatever parameters were passed to the ':new' message is sent to
  1053. X        the newly created object.
  1054. X
  1055. X        When a new class is created by sending the ':new' message to the
  1056. X        object 'Class', an optional parameter may be specified
  1057. X        indicating the superclass of the new class.  If this parameter
  1058. X        is omitted, the new class will be a subclass of 'Object'.  A
  1059. X        class inherits all instance variables, class variables, and
  1060. X        methods from its super-class.
  1061. X
  1062. X
  1063. X
  1064. X
  1065. X
  1066. X
  1067. X
  1068. X
  1069. X
  1070. X
  1071. X
  1072. X
  1073. X
  1074. X
  1075. X
  1076. X
  1077. X
  1078. X
  1079. X
  1080. X
  1081. X
  1082. X
  1083. X
  1084. X
  1085. X
  1086. X
  1087. X
  1088. X
  1089. X
  1090. X
  1091. X        XLISP                       SYMBOLS                      Page 17
  1092. X
  1093. X
  1094. X        SYMBOLS
  1095. X
  1096. X            o self - the current object (within a method context)
  1097. X            o *obarray* - the object hash table
  1098. X            o *standard-input* - the standard input stream
  1099. X            o *standard-output* - the standard output stream
  1100. X            o *error-output* - the error output stream
  1101. X            o *trace-output* - the trace output stream
  1102. X            o *debug-io* - the debug i/o stream
  1103. X            o *breakenable* - flag controlling entering break loop on errors
  1104. X            o *tracelist* - list of names of functions to trace
  1105. X            o *tracenable* - enable trace back printout on errors
  1106. X            o *tracelimit* - number of levels of trace back information
  1107. X            o *evalhook* - user substitute for the evaluator function
  1108. X            o *applyhook* - (not yet implemented)
  1109. X            o *readtable* - the current readtable
  1110. X            o *unbound* - indicator for unbound symbols
  1111. X            o *gc-flag* - controls the printing of gc messages
  1112. X            o *gc-hook* - function to call after garbage collection
  1113. X            o *integer-format* - format for printing integers ("%d" or "%ld")
  1114. X            o *float-format* - format for printing floats ("%g")
  1115. X            o *print-case* - symbol output case (:upcase or :downcase)
  1116. X
  1117. X        There are several symbols maintained by the read/eval/print
  1118. X        loop.  The symbols '+', '++', and '+++' are bound to the most
  1119. X        recent three input expressions.  The symbols '*', '**' and '***'
  1120. X        are bound to the most recent three results.  The symbol '-' is
  1121. X        bound to the expression currently being evaluated.  It becomes
  1122. X        the value of '+' at the end of the evaluation.
  1123. X
  1124. X
  1125. X
  1126. X
  1127. X
  1128. X
  1129. X
  1130. X
  1131. X
  1132. X
  1133. X
  1134. X
  1135. X
  1136. X
  1137. X
  1138. X
  1139. X
  1140. X
  1141. X
  1142. X
  1143. X
  1144. X
  1145. X
  1146. X
  1147. X
  1148. X
  1149. X
  1150. X
  1151. X
  1152. X
  1153. X
  1154. X
  1155. X
  1156. X
  1157. X        XLISP                 EVALUATION FUNCTIONS               Page 18
  1158. X
  1159. X
  1160. X        EVALUATION FUNCTIONS
  1161. X
  1162. X        (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  1163. X            <expr>      the expression to be evaluated
  1164. X            returns     the result of evaluating the expression
  1165. X
  1166. X        (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  1167. X            <fun>       the function to apply (or function symbol)
  1168. X            <args>      the argument list
  1169. X            returns     the result of applying the function to the arguments
  1170. X
  1171. X        (funcall <fun> <arg>...)  CALL A FUNCTION WITH ARGUMENTS
  1172. X            <fun>       the function to call (or function symbol)
  1173. X            <arg>       arguments to pass to the function
  1174. X            returns     the result of calling the function with the arguments
  1175. X
  1176. X        (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  1177. X            <expr>      the expression to be quoted (quoted)
  1178. X            returns     <expr> unevaluated
  1179. X
  1180. X        (function <expr>)  GET THE FUNCTIONAL INTERPRETATION
  1181. X            <expr>      the symbol or lambda expression (quoted)
  1182. X            returns     the functional interpretation
  1183. X
  1184. X        (backquote <expr>)  FILL IN A TEMPLATE
  1185. X            <expr>      the template
  1186. X            returns     a copy of the template with comma and comma-at
  1187. X                        expressions expanded
  1188. X
  1189. X        (lambda <args> <expr>...)  MAKE A FUNCTION CLOSURE
  1190. X            <args>      formal argument list (lambda list) (quoted)
  1191. X            <expr>      expressions of the function body
  1192. X            returns     the function closure
  1193. X
  1194. X        (get-lambda-expression <closure>)  GET THE LAMBDA EXPRESSION
  1195. X            <closure>   the closure
  1196. X            returns     the original lambda expression
  1197. X
  1198. X        (macroexpand <form>)  RECURSIVELY EXPAND MACRO CALLS
  1199. X            <form>      the form to expand
  1200. X            returns     the macro expansion
  1201. X
  1202. X        (macroexpand-1 <form>)  EXPAND A MACRO CALL
  1203. X            <form>      the macro call form
  1204. X            returns     the macro expansion
  1205. X
  1206. X
  1207. X
  1208. X
  1209. X
  1210. X
  1211. X
  1212. X
  1213. X
  1214. X
  1215. X
  1216. X
  1217. X
  1218. X
  1219. X
  1220. X
  1221. X
  1222. X
  1223. X        XLISP                   SYMBOL FUNCTIONS                 Page 19
  1224. X
  1225. X
  1226. X        SYMBOL FUNCTIONS
  1227. X
  1228. X        (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  1229. X            <sym>       the symbol being set
  1230. X            <expr>      the new value
  1231. X            returns     the new value
  1232. X
  1233. X        (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  1234. X            <sym>       the symbol being set (quoted)
  1235. X            <expr>      the new value
  1236. X            returns     the new value
  1237. X
  1238. X        (psetq [<sym> <expr>]...)  PARALLEL VERSION OF SETQ
  1239. X            <sym>       the symbol being set (quoted)
  1240. X            <expr>      the new value
  1241. X            returns     the new value
  1242. X
  1243. X        (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  1244. X            <place>     the field specifier (quoted):
  1245. X                          <sym>                   set value of a symbol
  1246. X                          (car <expr>)            set car of a cons node
  1247. X                          (cdr <expr>)            set cdr of a cons node
  1248. X                          (nth <n> <expr>)        set nth car of a list
  1249. X                          (aref <expr> <n>)       set nth element of an array
  1250. X                          (get <sym> <prop>)      set value of a property
  1251. X                          (symbol-value <sym>)    set value of a symbol
  1252. X                          (symbol-function <sym>) set functional value of a symbol
  1253. X                          (symbol-plist <sym>)    set property list of a symbol
  1254. X            <value>     the new value
  1255. X            returns     the new value
  1256. X
  1257. X        (defun <sym> <fargs> <expr>...)  DEFINE A FUNCTION
  1258. X        (defmacro <sym> <fargs> <expr>...)  DEFINE A MACRO
  1259. X            <sym>       symbol being defined (quoted)
  1260. X            <fargs>     formal argument list (lambda list) (quoted)
  1261. X            <expr>      expressions constituting the body of the
  1262. X                        function (quoted)
  1263. X            returns     the function symbol
  1264. X
  1265. X        (gensym [<tag>])  GENERATE A SYMBOL
  1266. X            <tag>       string or number
  1267. X            returns     the new symbol
  1268. X
  1269. X        (intern <pname>)  MAKE AN INTERNED SYMBOL
  1270. X            <pname>     the symbol's print name string
  1271. X            returns     the new symbol
  1272. X
  1273. X        (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  1274. X            <pname>     the symbol's print name string
  1275. X            returns     the new symbol
  1276. X
  1277. X        (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  1278. X            <sym>       the symbol
  1279. X            returns     the symbol's print name
  1280. X
  1281. X
  1282. X
  1283. X
  1284. X
  1285. X
  1286. X
  1287. X
  1288. X
  1289. X        XLISP                   SYMBOL FUNCTIONS                 Page 20
  1290. X
  1291. X
  1292. X        (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  1293. X            <sym>       the symbol
  1294. X            returns     the symbol's value
  1295. X
  1296. X        (symbol-function <sym>)  GET THE FUNCTIONAL VALUE OF A SYMBOL
  1297. X            <sym>       the symbol
  1298. X            returns     the symbol's functional value
  1299. X
  1300. X        (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  1301. X            <sym>       the symbol
  1302. X            returns     the symbol's property list
  1303. X
  1304. X        (hash <sym> <n>)  COMPUTE THE HASH INDEX FOR A SYMBOL
  1305. X            <sym>       the symbol or string
  1306. X            <n>         the table size (integer)
  1307. X            returns     the hash index (integer)
  1308. X
  1309. X
  1310. X
  1311. X
  1312. X
  1313. X
  1314. X
  1315. X
  1316. X
  1317. X
  1318. X
  1319. X
  1320. X
  1321. X
  1322. X
  1323. X
  1324. X
  1325. X
  1326. X
  1327. X
  1328. X
  1329. X
  1330. X
  1331. X
  1332. X
  1333. X
  1334. X
  1335. X
  1336. X
  1337. X
  1338. X
  1339. X
  1340. X
  1341. X
  1342. X
  1343. X
  1344. X
  1345. X
  1346. X
  1347. X
  1348. X
  1349. X
  1350. X
  1351. X
  1352. X
  1353. X
  1354. X
  1355. X        XLISP               PROPERTY LIST FUNCTIONS              Page 21
  1356. X
  1357. X
  1358. X        PROPERTY LIST FUNCTIONS
  1359. X
  1360. X        (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  1361. X            <sym>       the symbol
  1362. X            <prop>      the property symbol
  1363. X            returns     the property value or nil
  1364. X
  1365. X        (putprop <sym> <val> <prop>)  PUT A PROPERTY ONTO A PROPERTY LIST
  1366. X            <sym>       the symbol
  1367. X            <val>       the property value
  1368. X            <prop>      the property symbol
  1369. X            returns     the property value
  1370. X
  1371. X        (remprop <sym> <prop>)  REMOVE A PROPERTY
  1372. X            <sym>       the symbol
  1373. X            <prop>      the property symbol
  1374. X            returns     nil
  1375. X
  1376. X
  1377. X
  1378. X
  1379. X
  1380. X
  1381. X
  1382. X
  1383. X
  1384. X
  1385. X
  1386. X
  1387. X
  1388. X
  1389. X
  1390. X
  1391. X
  1392. X
  1393. X
  1394. X
  1395. X
  1396. X
  1397. X
  1398. X
  1399. X
  1400. X
  1401. X
  1402. X
  1403. X
  1404. X
  1405. X
  1406. X
  1407. X
  1408. X
  1409. X
  1410. X
  1411. X
  1412. X
  1413. X
  1414. X
  1415. X
  1416. X
  1417. X
  1418. X
  1419. X
  1420. X
  1421. X        XLISP                   ARRAY FUNCTIONS                  Page 22
  1422. X
  1423. X
  1424. X        ARRAY FUNCTIONS
  1425. X
  1426. X        (aref <array> <n>)  GET THE NTH ELEMENT OF AN ARRAY
  1427. X            <array>     the array
  1428. X            <n>         the array index (integer)
  1429. X            returns     the value of the array element
  1430. X
  1431. X        (make-array <size>)  MAKE A NEW ARRAY
  1432. X            <size>      the size of the new array (integer)
  1433. X            returns     the new array
  1434. X
  1435. X        (vector <expr>...)  MAKE AN INITIALIZED VECTOR
  1436. X            <expr>      the vector elements
  1437. X            returns     the new vector
  1438. X
  1439. X    (copy-array <src> <dest> [<dest-pos>])  COPY INTO A PREALLOC'd ARRAY
  1440. X         <src>    the array to copy from
  1441. X         <dest>    the array to copy to, preallocated by MAKE-ARRAY
  1442. X         <dest-pos>    the integer offset in <dest> for beginning the copy
  1443. X            If <dest-pos> is omitted, this defaults to 0.
  1444. X         returns    <dest>.
  1445. X
  1446. X    (array-insert-pos <array> <pos> <elt>)    INSERT A NEW ELEMENT IN ARRAY
  1447. X        <array>    an array into which we want to insert a new element
  1448. X        <pos>    the integer index in <array> for inserted element;
  1449. X            <pos> < 0 will cause the new element to be appended.
  1450. X        <elt>    any lisp value
  1451. X        returns    a new array that is one element longer than <array>;
  1452. X
  1453. X    (array-delete-pos <array> <pos>)  DELETE AN ELEMENT FROM AN ARRAY
  1454. X        <array>    an array into which we want to delete an element
  1455. X        <pos>    the integer index for the element to delete in <array>;
  1456. X            <pos> < 0 will delete the last element of the array.
  1457. X        returns    a new array that is one element shorter than <array>
  1458. X
  1459. X
  1460. X    NOTE: copy-array, array-insert-pos, and array-delete-pos are new
  1461. X    primitives added to XLISP by Niels Mayer for use with WINTERP.
  1462. X
  1463. X
  1464. X
  1465. X
  1466. X
  1467. X
  1468. X
  1469. X
  1470. X
  1471. X
  1472. X
  1473. X
  1474. X
  1475. X
  1476. X
  1477. X
  1478. X
  1479. X
  1480. X
  1481. X
  1482. X
  1483. X
  1484. X
  1485. X
  1486. X
  1487. X        XLISP                    LIST FUNCTIONS                  Page 23
  1488. X
  1489. X
  1490. X        LIST FUNCTIONS
  1491. X
  1492. X        (car <expr>)  RETURN THE CAR OF A LIST NODE
  1493. X            <expr>      the list node
  1494. X            returns     the car of the list node
  1495. X
  1496. X        (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  1497. X            <expr>      the list node
  1498. X            returns     the cdr of the list node
  1499. X
  1500. X        (cxxr <expr>)  ALL CxxR COMBINATIONS
  1501. X        (cxxxr <expr>)  ALL CxxxR COMBINATIONS
  1502. X        (cxxxxr <expr>)  ALL CxxxxR COMBINATIONS
  1503. X
  1504. X        (first <expr>)   A SYNONYM FOR CAR
  1505. X        (second <expr>)  A SYNONYM FOR CADR
  1506. X        (third <expr>)   A SYNONYM FOR CADDR
  1507. X        (fourth <expr>)  A SYNONYM FOR CADDDR
  1508. X        (rest <expr>)    A SYNONYM FOR CDR
  1509. X
  1510. X        (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  1511. X            <expr1>     the car of the new list node
  1512. X            <expr2>     the cdr of the new list node
  1513. X            returns     the new list node
  1514. X
  1515. X        (list <expr>...)  CREATE A LIST OF VALUES
  1516. X            <expr>      expressions to be combined into a list
  1517. X            returns     the new list
  1518. X
  1519. X        (append <expr>...)  APPEND LISTS
  1520. X            <expr>      lists whose elements are to be appended
  1521. X            returns     the new list
  1522. X
  1523. X        (reverse <expr>)  REVERSE A LIST
  1524. X            <expr>      the list to reverse
  1525. X            returns     a new list in the reverse order
  1526. X
  1527. X        (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  1528. X            <list>      the list
  1529. X            returns     the last list node in the list
  1530. X
  1531. X        (member <expr> <list> &key :test :test-not)  FIND AN EXPRESSION IN A LIST
  1532. X            <expr>      the expression to find
  1533. X            <list>      the list to search
  1534. X            :test       the test function (defaults to eql)
  1535. X            :test-not   the test function (sense inverted)      
  1536. X            returns     the remainder of the list starting with the expression
  1537. X
  1538. X        (assoc <expr> <alist> &key :test :test-not)  FIND AN EXPRESSION IN AN A-LIST
  1539. X            <expr>      the expression to find
  1540. X            <alist>     the association list
  1541. X            :test       the test function (defaults to eql)
  1542. X            :test-not   the test function (sense inverted)      
  1543. X            returns     the alist entry or nil
  1544. X
  1545. X
  1546. X
  1547. X
  1548. X
  1549. X
  1550. X
  1551. X
  1552. X
  1553. X        XLISP                    LIST FUNCTIONS                  Page 24
  1554. X
  1555. X
  1556. X        (remove <expr> <list> &key :test :test-not)  REMOVE ELEMENTS FROM A LIST
  1557. X            <expr>      the element to remove
  1558. X            <list>      the list
  1559. X            :test       the test function (defaults to eql)
  1560. X            :test-not   the test function (sense inverted)      
  1561. X            returns     copy of list with matching expressions removed
  1562. X
  1563. X        (remove-if <test> <list>)  REMOVE ELEMENTS THAT PASS TEST
  1564. X            <test>      the test predicate
  1565. X            <list>      the list
  1566. X            returns     copy of list with matching elements removed
  1567. X
  1568. X        (remove-if-not <test> <list>)  REMOVE ELEMENTS THAT FAIL TEST
  1569. X            <test>      the test predicate
  1570. X            <list>      the list
  1571. X            returns     copy of list with non-matching elements removed
  1572. X
  1573. X        (length <expr>)  FIND THE LENGTH OF A LIST, VECTOR OR STRING
  1574. X            <expr>      the list, vector or string
  1575. X            returns     the length of the list, vector or string
  1576. X
  1577. X        (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  1578. X            <n>         the number of the element to return (zero origin)
  1579. X            <list>      the list
  1580. X            returns     the nth element or nil if the list isn't that long
  1581. X
  1582. X        (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  1583. X            <n>         the number of the element to return (zero origin)
  1584. X            <list>      the list
  1585. X            returns     the nth cdr or nil if the list isn't that long
  1586. X
  1587. X        (mapc <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1588. X            <fcn>       the function or function name
  1589. X            <listn>     a list for each argument of the function
  1590. X            returns     the first list of arguments
  1591. X
  1592. X        (mapcar <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1593. X            <fcn>       the function or function name
  1594. X            <listn>     a list for each argument of the function
  1595. X            returns     a list of the values returned
  1596. X
  1597. X        (mapl <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1598. X            <fcn>       the function or function name
  1599. X            <listn>     a list for each argument of the function
  1600. X            returns     the first list of arguments
  1601. X
  1602. X        (maplist <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1603. X            <fcn>       the function or function name
  1604. X            <listn>     a list for each argument of the function
  1605. X            returns     a list of the values returned
  1606. X
  1607. X
  1608. X
  1609. X
  1610. X
  1611. X
  1612. X
  1613. X
  1614. X
  1615. X
  1616. X
  1617. X
  1618. X
  1619. X        XLISP                    LIST FUNCTIONS                  Page 25
  1620. X
  1621. X
  1622. X        (subst <to> <from> <expr> &key :test :test-not)  SUBSTITUTE EXPRESSIONS
  1623. X            <to>        the new expression
  1624. X            <from>      the old expression
  1625. X            <expr>      the expression in which to do the substitutions
  1626. X            :test       the test function (defaults to eql)
  1627. X            :test-not   the test function (sense inverted)      
  1628. X            returns     the expression with substitutions
  1629. X
  1630. X        (sublis <alist> <expr> &key :test :test-not)  SUBSTITUTE WITH AN A-LIST
  1631. X            <alist>     the association list
  1632. X            <expr>      the expression in which to do the substitutions
  1633. X            :test       the test function (defaults to eql)
  1634. X            :test-not   the test function (sense inverted)      
  1635. X            returns     the expression with substitutions
  1636. X
  1637. X
  1638. X
  1639. X
  1640. X
  1641. X
  1642. X
  1643. X
  1644. X
  1645. X
  1646. X
  1647. X
  1648. X
  1649. X
  1650. X
  1651. X
  1652. X
  1653. X
  1654. X
  1655. X
  1656. X
  1657. X
  1658. X
  1659. X
  1660. X
  1661. X
  1662. X
  1663. X
  1664. X
  1665. X
  1666. X
  1667. X
  1668. X
  1669. X
  1670. X
  1671. X
  1672. X
  1673. X
  1674. X
  1675. X
  1676. X
  1677. X
  1678. X
  1679. X
  1680. X
  1681. X
  1682. X
  1683. X
  1684. X
  1685. X        XLISP              DESTRUCTIVE LIST FUNCTIONS            Page 26
  1686. X
  1687. X
  1688. X        DESTRUCTIVE LIST FUNCTIONS
  1689. X
  1690. X        (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  1691. X            <list>      the list node
  1692. X            <expr>      the new value for the car of the list node
  1693. X            returns     the list node after updating the car
  1694. X
  1695. X        (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  1696. X            <list>      the list node
  1697. X            <expr>      the new value for the cdr of the list node
  1698. X            returns     the list node after updating the cdr
  1699. X
  1700. X        (nconc <list>...)  DESTRUCTIVELY CONCATENATE LISTS
  1701. X            <list>      lists to concatenate
  1702. X            returns     the result of concatenating the lists
  1703. X
  1704. X        (delete <expr> &key :test :test-not)  DELETE ELEMENTS FROM A LIST
  1705. X            <expr>      the element to delete
  1706. X            <list>      the list
  1707. X            :test       the test function (defaults to eql)
  1708. X            :test-not   the test function (sense inverted)      
  1709. X            returns     the list with the matching expressions deleted
  1710. X
  1711. X        (delete-if <test> <list>)  DELETE ELEMENTS THAT PASS TEST
  1712. X            <test>      the test predicate
  1713. X            <list>      the list
  1714. X            returns     the list with matching elements deleted
  1715. X
  1716. X        (delete-if-not <test> <list>)  DELETE ELEMENTS THAT FAIL TEST
  1717. X            <test>      the test predicate
  1718. X            <list>      the list
  1719. X            returns     the list with non-matching elements deleted
  1720. X
  1721. X        (sort <list> <test>)  SORT A LIST
  1722. X            <list>      the list to sort
  1723. X            <test>      the comparison function
  1724. X            returns     the sorted list
  1725. X
  1726. X
  1727. X
  1728. X
  1729. X
  1730. X
  1731. X
  1732. X
  1733. X
  1734. X
  1735. X
  1736. X
  1737. X
  1738. X
  1739. X
  1740. X
  1741. X
  1742. X
  1743. X
  1744. X
  1745. X
  1746. X
  1747. X
  1748. X
  1749. X
  1750. X
  1751. X        XLISP                 PREDICATE FUNCTIONS                Page 27
  1752. X
  1753. X
  1754. X        PREDICATE FUNCTIONS
  1755. X
  1756. X        (atom <expr>)  IS THIS AN ATOM?
  1757. X            <expr>      the expression to check
  1758. X            returns     t if the value is an atom, nil otherwise
  1759. X
  1760. X        (symbolp <expr>)  IS THIS A SYMBOL?
  1761. X            <expr>      the expression to check
  1762. X            returns     t if the expression is a symbol, nil otherwise
  1763. X
  1764. X        (numberp <expr>)  IS THIS A NUMBER?
  1765. X            <expr>      the expression to check
  1766. X            returns     t if the expression is a number, nil otherwise
  1767. X
  1768. X        (null <expr>)  IS THIS AN EMPTY LIST?
  1769. X            <expr>      the list to check
  1770. X            returns     t if the list is empty, nil otherwise
  1771. X
  1772. X        (not <expr>)  IS THIS FALSE?
  1773. X            <expr>      the expression to check
  1774. X            return      t if the value is nil, nil otherwise
  1775. X
  1776. X        (listp <expr>)  IS THIS A LIST?
  1777. X            <expr>      the expression to check
  1778. X            returns     t if the value is a cons or nil, nil otherwise
  1779. X
  1780. X        (endp <list>)  IS THIS THE END OF A LIST
  1781. X            <list>      the list
  1782. X            returns     t if the value is nil, nil otherwise
  1783. X
  1784. X        (consp <expr>)  IS THIS A NON-EMPTY LIST?
  1785. X            <expr>      the expression to check
  1786. X            returns     t if the value is a cons, nil otherwise
  1787. X
  1788. X        (integerp <expr>)  IS THIS AN INTEGER?
  1789. X            <expr>      the expression to check
  1790. X            returns     t if the value is an integer, nil otherwise
  1791. X
  1792. X        (floatp <expr>)  IS THIS A FLOAT?
  1793. X            <expr>      the expression to check
  1794. X            returns     t if the value is a float, nil otherwise
  1795. X
  1796. X        (stringp <expr>)  IS THIS A STRING?
  1797. X            <expr>      the expression to check
  1798. X            returns     t if the value is a string, nil otherwise
  1799. X
  1800. X        (characterp <expr>)  IS THIS A CHARACTER?
  1801. X            <expr>      the expression to check
  1802. X            returns     t if the value is a character, nil otherwise
  1803. X
  1804. X        (arrayp <expr>)  IS THIS AN ARRAY?
  1805. X            <expr>      the expression to check
  1806. X            returns     t if the value is an array, nil otherwise
  1807. X
  1808. X
  1809. X
  1810. X
  1811. X
  1812. X
  1813. X
  1814. X
  1815. X
  1816. X
  1817. X        XLISP                 PREDICATE FUNCTIONS                Page 28
  1818. X
  1819. X
  1820. X        (streamp <expr>)  IS THIS A STREAM?
  1821. X            <expr>      the expression to check
  1822. X            returns     t if the value is a stream, nil otherwise
  1823. X
  1824. X        (objectp <expr>)  IS THIS AN OBJECT?
  1825. X            <expr>      the expression to check
  1826. X            returns     t if the value is an object, nil otherwise
  1827. X
  1828. X#ifdef WINTERP
  1829. X        (widgetobjp <expr>)  IS THIS A WIDGETOBJ?
  1830. X            <expr>      the expression to check
  1831. X            returns     t if the value is an object, nil otherwise
  1832. X#endif
  1833. X
  1834. X        (boundp <sym>)  IS A VALUE BOUND TO THIS SYMBOL?
  1835. X            <sym>       the symbol
  1836. X            returns     t if a value is bound to the symbol, nil otherwise
  1837. X
  1838. X        (fboundp <sym>)  IS A FUNCTIONAL VALUE BOUND TO THIS SYMBOL?
  1839. X            <sym>       the symbol
  1840. X            returns     t if a functional value is bound to the symbol,
  1841. X                        nil otherwise
  1842. X
  1843. X        (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  1844. X            <expr>      the number to test
  1845. X            returns     t if the number is negative, nil otherwise
  1846. X
  1847. X        (zerop <expr>)  IS THIS NUMBER ZERO?
  1848. X            <expr>      the number to test
  1849. X            returns     t if the number is zero, nil otherwise
  1850. X
  1851. X        (plusp <expr>)  IS THIS NUMBER POSITIVE?
  1852. X            <expr>      the number to test
  1853. X            returns     t if the number is positive, nil otherwise
  1854. X
  1855. X        (evenp <expr>)  IS THIS INTEGER EVEN?
  1856. X            <expr>      the integer to test
  1857. X            returns     t if the integer is even, nil otherwise
  1858. X
  1859. X        (oddp <expr>)  IS THIS INTEGER ODD?
  1860. X            <expr>      the integer to test
  1861. X            returns     t if the integer is odd, nil otherwise
  1862. X
  1863. X        (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1864. X            <expr1>     the first expression
  1865. X            <expr2>     the second expression
  1866. X            returns     t if they are equal, nil otherwise
  1867. X
  1868. X        (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1869. X                                (WORKS WITH ALL NUMBERS)
  1870. X            <expr1>     the first expression
  1871. X            <expr2>     the second expression
  1872. X            returns     t if they are equal, nil otherwise
  1873. X
  1874. X        (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  1875. X            <expr1>     the first expression
  1876. X            <expr2>     the second expression
  1877. X            returns     t if they are equal, nil otherwise
  1878. X
  1879. X
  1880. X
  1881. X
  1882. X
  1883. X        XLISP                  CONTROL CONSTRUCTS                Page 29
  1884. X
  1885. X
  1886. X        CONTROL CONSTRUCTS
  1887. X
  1888. X        (cond <pair>...)  EVALUATE CONDITIONALLY
  1889. X            <pair>      pair consisting of:
  1890. X                            (<pred> <expr>...)
  1891. X                          where
  1892. X                            <pred>      is a predicate expression
  1893. X                            <expr>      evaluated if the predicate
  1894. X                                        is not nil
  1895. X            returns     the value of the first expression whose predicate
  1896. X                        is not nil
  1897. X
  1898. X        (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  1899. X            <expr>      the expressions to be ANDed
  1900. X            returns     nil if any expression evaluates to nil,
  1901. X                        otherwise the value of the last expression
  1902. X                        (evaluation of expressions stops after the first
  1903. X                         expression that evaluates to nil)
  1904. X
  1905. X        (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  1906. X            <expr>      the expressions to be ORed
  1907. X            returns     nil if all expressions evaluate to nil,
  1908. X                        otherwise the value of the first non-nil expression
  1909. X                        (evaluation of expressions stops after the first
  1910. X                         expression that does not evaluate to nil)
  1911. X
  1912. X        (if <texpr> <expr1> [<expr2>])  EVALUATE EXPRESSIONS CONDITIONALLY
  1913. X            <texpr>     the test expression
  1914. X            <expr1>     the expression to be evaluated if texpr is non-nil
  1915. X            <expr2>     the expression to be evaluated if texpr is nil
  1916. X            returns     the value of the selected expression
  1917. X
  1918. X        (when <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS TRUE
  1919. X            <texpr>     the test expression
  1920. X            <expr>      the expression(s) to be evaluted if texpr is non-nil
  1921. X            returns     the value of the last expression or nil
  1922. X
  1923. X        (unless <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS FALSE
  1924. X            <texpr>     the test expression
  1925. X            <expr>      the expression(s) to be evaluated if texpr is nil
  1926. X            returns     the value of the last expression or nil
  1927. X
  1928. X          (case <expr> <case>...)  SELECT BY CASE
  1929. X            <expr>      the selection expression
  1930. X            <case>      pair consisting of:
  1931. X                            (<value> <expr>...)
  1932. X                          where:
  1933. X                            <value>     is a single expression or a list of
  1934. X                                        expressions (unevaluated)
  1935. X                            <expr>      are expressions to execute if the
  1936. X                                        case matches
  1937. X            returns     the value of the last expression of the matching case
  1938. X
  1939. X
  1940. X
  1941. X
  1942. X
  1943. X
  1944. X
  1945. X
  1946. X
  1947. X
  1948. X
  1949. X        XLISP                  CONTROL CONSTRUCTS                Page 30
  1950. X
  1951. X
  1952. X        (let (<binding>...) <expr>...)  CREATE LOCAL BINDINGS
  1953. X        (let* (<binding>...) <expr>...)  LET WITH SEQUENTIAL BINDING
  1954. X            <binding>   the variable bindings each of which is either:
  1955. X                        1)  a symbol (which is initialized to nil)
  1956. X                        2)  a list whose car is a symbol and whose cadr
  1957. X                                is an initialization expression
  1958. X            <expr>      the expressions to be evaluated
  1959. X            returns     the value of the last expression
  1960. X
  1961. X        (flet (<binding>...) <expr>...)  CREATE LOCAL FUNCTIONS
  1962. X        (labels (<binding>...) <expr>...)  FLET WITH RECURSIVE FUNCTIONS
  1963. X        (macrolet (<binding>...) <expr>...)  CREATE LOCAL MACROS
  1964. X            <binding>   the function bindings each of which is:
  1965. X                          (<sym> <fargs> <expr>...)
  1966. X                        where:
  1967. X                            <sym>       the function/macro name
  1968. X                            <fargs>     formal argument list (lambda list)
  1969. X                            <expr>      expressions constituting the body of
  1970. X                                        the function/macro
  1971. X            <expr>      the expressions to be evaluated
  1972. X            returns     the value of the last expression
  1973. X
  1974. X        (catch <sym> <expr>...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  1975. X            <sym>       the catch tag
  1976. X            <expr>      expressions to evaluate
  1977. X            returns     the value of the last expression the throw expression
  1978. X
  1979. X        (throw <sym> [<expr>])  THROW TO A CATCH
  1980. X            <sym>       the catch tag
  1981. X            <expr>      the value for the catch to return (defaults to nil)
  1982. X            returns     never returns
  1983. X
  1984. X        (unwind-protect <expr> <cexpr>...)  PROTECT EVALUATION OF AN EXPRESSION
  1985. X            <expr>      the expression to protect
  1986. X            <cexpr>     the cleanup expressions
  1987. X            returns     the value of the expression
  1988. X          Note:  unwind-protect guarantees to execute the cleanup expressions
  1989. X                 even if a non-local exit terminates the evaluation of the
  1990. X                 protected expression
  1991. X
  1992. X
  1993. X
  1994. X
  1995. X
  1996. X
  1997. X
  1998. X
  1999. X
  2000. X
  2001. X
  2002. X
  2003. X
  2004. X
  2005. X
  2006. X
  2007. X
  2008. X
  2009. X
  2010. X
  2011. X
  2012. X
  2013. X
  2014. X
  2015. X        XLISP                  LOOPING CONSTRUCTS                Page 31
  2016. X
  2017. X
  2018. X        LOOPING CONSTRUCTS
  2019. X
  2020. X        (loop <expr>...)  BASIC LOOPING FORM
  2021. X            <expr>      the body of the loop
  2022. X            returns     never returns (must use non-local exit)
  2023. X
  2024. X        (do (<binding>...) (<texpr> <rexpr>...) <expr>...)
  2025. X        (do* (<binding>...) (<texpr> <rexpr>...) <expr>...)
  2026. X            <binding>   the variable bindings each of which is either:
  2027. X                        1)  a symbol (which is initialized to nil)
  2028. X                        2)  a list of the form: (<sym> <init> [<step>])
  2029. X                            where:
  2030. X                                <sym>  is the symbol to bind
  2031. X                                <init> is the initial value of the symbol
  2032. X                                <step> is a step expression
  2033. X            <texpr>     the termination test expression
  2034. X            <rexpr>     result expressions (the default is nil)
  2035. X            <expr>      the body of the loop (treated like an implicit prog)
  2036. X            returns     the value of the last result expression
  2037. X
  2038. X        (dolist (<sym> <expr> [<rexpr>]) <expr>...)  LOOP THROUGH A LIST
  2039. X            <sym>       the symbol to bind to each list element
  2040. X            <expr>      the list expression
  2041. X            <rexpr>     the result expression (the default is nil)
  2042. X            <expr>      the body of the loop (treated like an implicit prog)
  2043. X
  2044. X        (dotimes (<sym> <expr> [<rexpr>]) <expr>...)  LOOP FROM ZERO TO N-1
  2045. X            <sym>       the symbol to bind to each value from 0 to n-1
  2046. X            <expr>      the number of times to loop
  2047. X            <rexpr>     the result expression (the default is nil)
  2048. X            <expr>      the body of the loop (treated like an implicit prog)
  2049. X
  2050. X
  2051. X
  2052. X
  2053. X
  2054. X
  2055. X
  2056. X
  2057. X
  2058. X
  2059. X
  2060. X
  2061. X
  2062. X
  2063. X
  2064. X
  2065. X
  2066. X
  2067. X
  2068. X
  2069. X
  2070. X
  2071. X
  2072. X
  2073. X
  2074. X
  2075. X
  2076. X
  2077. X
  2078. X
  2079. X
  2080. X
  2081. X        XLISP                 THE PROGRAM FEATURE                Page 32
  2082. X
  2083. X
  2084. X        THE PROGRAM FEATURE
  2085. X
  2086. X        (prog (<binding>...) <expr>...)  THE PROGRAM FEATURE
  2087. X        (prog* (<binding>...) <expr>...)  PROG WITH SEQUENTIAL BINDING
  2088. X            <binding>   the variable bindings each of which is either:
  2089. X                        1)  a symbol (which is initialized to nil)
  2090. X                        2)  a list whose car is a symbol and whose cadr
  2091. X                                is an initialization expression
  2092. X            <expr>      expressions to evaluate or tags (symbols)
  2093. X            returns     nil or the argument passed to the return function
  2094. X
  2095. X        (block <name> <expr>...)  NAMED BLOCK
  2096. X            <name>      the block name (symbol)
  2097. X            <expr>      the block body
  2098. X            returns     the value of the last expression
  2099. X
  2100. X        (return [<expr>])  CAUSE A PROG CONSTRUCT TO RETURN A VALUE
  2101. X            <expr>      the value (defaults to nil)
  2102. X            returns     never returns
  2103. X
  2104. X        (return-from <name> [<value>])  RETURN FROM A NAMED BLOCK
  2105. X            <name>      the block name (symbol)
  2106. X            <value>     the value to return (defaults to nil)
  2107. X            returns     never returns
  2108. X
  2109. X        (tagbody <expr>...)  BLOCK WITH LABELS
  2110. X            <expr>      expression(s) to evaluate or tags (symbols)
  2111. X            returns     nil
  2112. X
  2113. X        (go <sym>)  GO TO A TAG WITHIN A TAGBODY OR PROG
  2114. X            <sym>       the tag (quoted)
  2115. X            returns     never returns
  2116. X
  2117. X        (progv <slist> <vlist> <expr>...)  DYNAMICALLY BIND SYMBOLS
  2118. X            <slist>     list of symbols
  2119. X            <vlist>     list of values to bind to the symbols
  2120. X            <expr>      expression(s) to evaluate
  2121. X            returns     the value of the last expression
  2122. X
  2123. X        (prog1 <expr1> <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2124. X            <expr1>     the first expression to evaluate
  2125. X            <expr>      the remaining expressions to evaluate
  2126. X            returns     the value of the first expression
  2127. X
  2128. X        (prog2 <expr1> <expr2> <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2129. X            <expr1>     the first expression to evaluate
  2130. X            <expr2>     the second expression to evaluate
  2131. X            <expr>      the remaining expressions to evaluate
  2132. X            returns     the value of the second expression
  2133. X
  2134. X        (progn <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2135. X            <expr>      the expressions to evaluate
  2136. X            returns     the value of the last expression (or nil)
  2137. X
  2138. X
  2139. X
  2140. X
  2141. X
  2142. X
  2143. X
  2144. X
  2145. X
  2146. X
  2147. X        XLISP             DEBUGGING AND ERROR HANDLING           Page 33
  2148. X
  2149. X
  2150. X        DEBUGGING AND ERROR HANDLING
  2151. X
  2152. X        (trace <sym>)  ADD A FUNCTION TO THE TRACE LIST
  2153. X            <sym>       the function to add (quoted)
  2154. X            returns     the trace list
  2155. X
  2156. X        (untrace <sym>)  REMOVE A FUNCTION FROM THE TRACE LIST
  2157. X            <sym>       the function to remove (quoted)
  2158. X            returns     the trace list
  2159. X
  2160. X        (error <emsg> [<arg>])  SIGNAL A NON-CORRECTABLE ERROR
  2161. X            <emsg>      the error message string
  2162. X            <arg>       the argument expression (printed after the message)
  2163. X            returns     never returns
  2164. X
  2165. X        (cerror <cmsg> <emsg> [<arg>])  SIGNAL A CORRECTABLE ERROR
  2166. X            <cmsg>      the continue message string
  2167. X            <emsg>      the error message string
  2168. X            <arg>       the argument expression (printed after the message)
  2169. X            returns     nil when continued from the break loop
  2170. X
  2171. X        (break [<bmsg> [<arg>]])  ENTER A BREAK LOOP
  2172. X            <bmsg>      the break message string (defaults to "**BREAK**")
  2173. X            <arg>       the argument expression (printed after the message)
  2174. X            returns     nil when continued from the break loop
  2175. X
  2176. X        (clean-up)  CLEAN-UP AFTER AN ERROR
  2177. X            returns     never returns
  2178. X
  2179. X        (top-level)  CLEAN-UP AFTER AN ERROR AND RETURN TO THE TOP LEVEL
  2180. X            returns     never returns
  2181. X
  2182. X        (continue)  CONTINUE FROM A CORRECTABLE ERROR
  2183. X            returns     never returns
  2184. X
  2185. X        (errset <expr> [<pflag>])  TRAP ERRORS
  2186. X            <expr>      the expression to execute
  2187. X            <pflag>     flag to control printing of the error message
  2188. X            returns     the value of the last expression consed with nil
  2189. X                        or nil on error
  2190. X
  2191. X        (baktrace [<n>])  PRINT N LEVELS OF TRACE BACK INFORMATION
  2192. X            <n>         the number of levels (defaults to all levels)
  2193. X            returns     nil
  2194. X
  2195. X        (evalhook <expr> <ehook> <ahook> [<env>])  EVALUATE WITH HOOKS
  2196. X            <expr>      the expression to evaluate
  2197. X            <ehook>     the value for *evalhook*
  2198. X            <ahook>     the value for *applyhook*
  2199. X            <env>       the environment (default is nil)
  2200. X            returns     the result of evaluating the expression
  2201. X
  2202. X
  2203. X
  2204. X
  2205. X
  2206. X
  2207. X
  2208. X
  2209. X
  2210. X
  2211. X
  2212. X
  2213. X        XLISP                 ARITHMETIC FUNCTIONS               Page 34
  2214. X
  2215. X
  2216. X        ARITHMETIC FUNCTIONS
  2217. X
  2218. X        (truncate <expr>)  TRUNCATES A FLOATING POINT NUMBER TO AN INTEGER
  2219. X            <expr>      the number
  2220. X            returns     the result of truncating the number
  2221. X
  2222. X        (float <expr>)  CONVERTS AN INTEGER TO A FLOATING POINT NUMBER
  2223. X            <expr>      the number
  2224. X            returns     the result of floating the integer
  2225. X
  2226. X        (+ <expr>...)  ADD A LIST OF NUMBERS
  2227. X            <expr>      the numbers
  2228. X            returns     the result of the addition
  2229. X
  2230. X        (- <expr>...)  SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
  2231. X            <expr>      the numbers
  2232. X            returns     the result of the subtraction
  2233. X
  2234. X        (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  2235. X            <expr>      the numbers
  2236. X            returns     the result of the multiplication
  2237. X
  2238. X        (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  2239. X            <expr>      the numbers
  2240. X            returns     the result of the division
  2241. X
  2242. X        (1+ <expr>)  ADD ONE TO A NUMBER
  2243. X            <expr>      the number
  2244. X            returns     the number plus one
  2245. X
  2246. X        (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  2247. X            <expr>      the number
  2248. X            returns     the number minus one
  2249. X
  2250. X        (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  2251. X            <expr>      the numbers
  2252. X            returns     the result of the remainder operation
  2253. X
  2254. X        (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  2255. X            <expr>      the expressions to be checked
  2256. X            returns     the smallest number in the list
  2257. X
  2258. X        (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  2259. X            <expr>      the expressions to be checked
  2260. X            returns     the largest number in the list
  2261. X
  2262. X        (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  2263. X            <expr>      the number
  2264. X            returns     the absolute value of the number
  2265. X
  2266. X        (gcd <n1> <n2>...)  COMPUTE THE GREATEST COMMON DIVISOR
  2267. X            <n1>        the first number (integer)
  2268. X            <n2>        the second number(s) (integer)
  2269. X            returns     the greatest common divisor
  2270. X
  2271. X
  2272. X
  2273. X
  2274. X
  2275. X
  2276. X
  2277. X
  2278. X
  2279. X        XLISP                 ARITHMETIC FUNCTIONS               Page 35
  2280. X
  2281. X
  2282. X        (random <n>)  COMPUTE A RANDOM NUMBER BETWEEN 1 and N-1
  2283. X            <n>         the upper bound (integer)
  2284. X            returns     a random number
  2285. X
  2286. X        (sin <expr>)  COMPUTE THE SINE OF A NUMBER
  2287. X            <expr>      the floating point number
  2288. X            returns     the sine of the number
  2289. X
  2290. X        (cos <expr>)  COMPUTE THE COSINE OF A NUMBER
  2291. X            <expr>      the floating point number
  2292. X            returns     the cosine of the number
  2293. X
  2294. X        (tan <expr>)  COMPUTE THE TANGENT OF A NUMBER
  2295. X            <expr>      the floating point number
  2296. X            returns     the tangent of the number
  2297. X
  2298. X        (asin <expr>)  COMPUTE THE ARC SINE OF A NUMBER
  2299. X            <expr>      the floating point number
  2300. X            returns     the arc sine of the number
  2301. X
  2302. X        (acos <expr>)  COMPUTE THE ARC COSINE OF A NUMBER
  2303. X            <expr>      the floating point number
  2304. X            returns     the arc cosine of the number
  2305. X
  2306. X        (atan <expr>)  COMPUTE THE ARC TANGENT OF A NUMBER
  2307. X            <expr>      the floating point number
  2308. X            returns     the arc tangent of the number
  2309. X
  2310. X        (expt <x-expr> <y-expr>)  COMPUTE X TO THE Y POWER
  2311. X            <x-expr>    the floating point number
  2312. X            <y-expr>    the floating point exponent
  2313. X            returns     x to the y power
  2314. X
  2315. X        (exp <x-expr>)  COMPUTE E TO THE X POWER
  2316. X            <x-expr>    the floating point number
  2317. X            returns     e to the x power
  2318. X
  2319. X        (sqrt <expr>)  COMPUTE THE SQUARE ROOT OF A NUMBER
  2320. X            <expr>      the floating point number
  2321. X            returns     the square root of the number
  2322. X
  2323. X        (< <n1> <n2>...)  TEST FOR LESS THAN
  2324. X        (<= <n1> <n2>...)  TEST FOR LESS THAN OR EQUAL TO
  2325. X        (= <n1> <n2>...)  TEST FOR EQUAL TO
  2326. X        (/= <n1> <n2>...)  TEST FOR NOT EQUAL TO
  2327. X        (>= <n1> <n2>...)  TEST FOR GREATER THAN OR EQUAL TO
  2328. X        (> <n1> <n2>...)  TEST FOR GREATER THAN
  2329. X            <n1>        the first number to compare
  2330. X            <n2>        the second number to compare
  2331. X            returns     the result of comparing <n1> with <n2>...
  2332. X
  2333. X
  2334. X
  2335. X
  2336. X
  2337. X
  2338. X
  2339. X
  2340. X
  2341. X
  2342. X
  2343. X
  2344. X
  2345. X        XLISP              BITWISE LOGICAL FUNCTIONS             Page 36
  2346. X
  2347. X
  2348. X        BITWISE LOGICAL FUNCTIONS
  2349. X
  2350. X        (logand <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  2351. X            <expr>      the numbers
  2352. X            returns     the result of the and operation
  2353. X
  2354. X        (logior <expr>...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  2355. X            <expr>      the numbers
  2356. X            returns     the result of the inclusive or operation
  2357. X
  2358. X        (logxor <expr>...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  2359. X            <expr>      the numbers
  2360. X            returns     the result of the exclusive or operation
  2361. X
  2362. X        (lognot <expr>)  THE BITWISE NOT OF A NUMBER
  2363. X            <expr>      the number
  2364. X            returns     the bitwise inversion of number
  2365. X
  2366. X
  2367. X
  2368. X
  2369. X
  2370. X
  2371. X
  2372. X
  2373. X
  2374. X
  2375. X
  2376. X
  2377. X
  2378. X
  2379. X
  2380. X
  2381. X
  2382. X
  2383. X
  2384. X
  2385. X
  2386. X
  2387. X
  2388. X
  2389. X
  2390. X
  2391. X
  2392. X
  2393. X
  2394. X
  2395. X
  2396. X
  2397. X
  2398. X
  2399. X
  2400. X
  2401. X
  2402. X
  2403. X
  2404. X
  2405. X
  2406. X
  2407. X
  2408. X
  2409. X
  2410. X
  2411. X        XLISP                   STRING FUNCTIONS                 Page 37
  2412. X
  2413. X
  2414. X        STRING FUNCTIONS
  2415. X
  2416. X        (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  2417. X            <expr>      the integer
  2418. X            returns     a one character string
  2419. X
  2420. X        (string-trim <bag> <str>)  TRIM BOTH ENDS OF A STRING
  2421. X            <bag>       a string containing characters to trim
  2422. X            <str>       the string to trim
  2423. X            returns     a trimed copy of the string
  2424. X
  2425. X        (string-left-trim <bag> <str>)  TRIM THE LEFT END OF A STRING
  2426. X            <bag>       a string containing characters to trim
  2427. X            <str>       the string to trim
  2428. X            returns     a trimed copy of the string
  2429. X
  2430. X        (string-right-trim <bag> <str>)  TRIM THE RIGHT END OF A STRING
  2431. X            <bag>       a string containing characters to trim
  2432. X            <str>       the string to trim
  2433. X            returns     a trimed copy of the string
  2434. X
  2435. X        (string-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2436. X            <str>       the string
  2437. X            :start      the starting offset
  2438. X            :end        the ending offset + 1
  2439. X            returns     a converted copy of the string
  2440. X
  2441. X        (string-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2442. X            <str>       the string
  2443. X            :start      the starting offset
  2444. X            :end        the ending offset + 1
  2445. X            returns     a converted copy of the string
  2446. X
  2447. X        (nstring-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2448. X            <str>       the string
  2449. X            :start      the starting offset
  2450. X            :end        the ending offset + 1
  2451. X            returns     the converted string (not a copy)
  2452. X
  2453. X        (nstring-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2454. X            <str>       the string
  2455. X            :start      the starting offset
  2456. X            :end        the ending offset + 1
  2457. X            returns     the converted string (not a copy)
  2458. X
  2459. X        (strcat <expr>...)  CONCATENATE STRINGS
  2460. X            <expr>      the strings to concatenate
  2461. X            returns     the result of concatenating the strings
  2462. X
  2463. X        (subseq <string> <start> [<end>]) EXTRACT A SUBSTRING
  2464. X            <string>    the string
  2465. X            <start>     the starting position (zero origin)
  2466. X            <end>       the ending position + 1 (defaults to end)
  2467. X            returns     substring between <start> and <end>
  2468. X
  2469. X
  2470. X
  2471. X
  2472. X
  2473. X
  2474. X
  2475. X
  2476. X
  2477. X        XLISP                   STRING FUNCTIONS                 Page 38
  2478. X
  2479. X
  2480. X        (string< <str1> <str2> &key :start1 :end1 :start2 :end2)
  2481. X        (string<= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2482. X        (string= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2483. X        (string/= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2484. X        (string>= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2485. X        (string> <str1> <str2> &key :start1 :end1 :start2 :end2)
  2486. X            <str1>      the first string to compare
  2487. X            <str2>      the second string to compare
  2488. X            :start1     first substring starting offset
  2489. X            :end1       first substring ending offset + 1
  2490. X            :start2     second substring starting offset
  2491. X            :end2       second substring ending offset + 1
  2492. X            returns     t if predicate is true, nil otherwise
  2493. X          Note: case is significant with these comparison functions.
  2494. X
  2495. X        (string-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2496. X        (string-not-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2497. X        (string-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2498. X        (string-not-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2499. X        (string-not-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2500. X        (string-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2501. X            <str1>      the first string to compare
  2502. X            <str2>      the second string to compare
  2503. X            :start1     first substring starting offset
  2504. X            :end1       first substring ending offset + 1
  2505. X            :start2     second substring starting offset
  2506. X            :end2       second substring ending offset + 1
  2507. X            returns     t if predicate is true, nil otherwise
  2508. X          Note: case is not significant with these comparison functions.
  2509. X
  2510. X
  2511. X
  2512. X
  2513. X
  2514. X
  2515. X
  2516. X
  2517. X
  2518. X
  2519. X
  2520. X
  2521. X
  2522. X
  2523. X
  2524. X
  2525. X
  2526. X
  2527. X
  2528. X
  2529. X
  2530. X
  2531. X
  2532. X
  2533. X
  2534. X
  2535. X
  2536. X
  2537. X
  2538. X
  2539. X
  2540. X
  2541. X
  2542. X
  2543. X        XLISP                 CHARACTER FUNCTIONS                Page 39
  2544. X
  2545. X
  2546. X        CHARACTER FUNCTIONS
  2547. X
  2548. X        (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  2549. X            <string>    the string
  2550. X            <index>     the string index (zero relative)
  2551. X            returns     the ascii code of the character
  2552. X
  2553. X        (upper-case-p <chr>)  IS THIS AN UPPER CASE CHARACTER?
  2554. X            <chr>       the character
  2555. X            returns     true if the character is upper case, nil otherwise
  2556. X
  2557. X        (lower-case-p <chr>)  IS THIS A LOWER CASE CHARACTER?
  2558. X            <chr>       the character
  2559. X            returns     true if the character is lower case, nil otherwise
  2560. X
  2561. X        (both-case-p <chr>)  IS THIS AN ALPHABETIC (EITHER CASE) CHARACTER?
  2562. X            <chr>       the character
  2563. X            returns     true if the character is alphabetic, nil otherwise
  2564. X
  2565. X        (digit-char-p <chr>)  IS THIS A DIGIT CHARACTER?
  2566. X            <chr>       the character
  2567. X            returns     the digit weight if character is a digit, nil otherwise
  2568. X
  2569. X        (char-code <chr>)  GET THE ASCII CODE OF A CHARACTER
  2570. X            <chr>       the character
  2571. X            returns     the ASCII character code (integer)
  2572. X
  2573. X        (code-char <code>)  GET THE CHARACTER WITH A SPECFIED ASCII CODE
  2574. X            <code>      the ASCII code (integer)
  2575. X            returns     the character with that code or nil
  2576. X
  2577. X        (char-upcase <chr>)  CONVERT A CHARACTER TO UPPER CASE
  2578. X            <chr>       the character
  2579. X            returns     the upper case character
  2580. X
  2581. X        (char-downcase <chr>)  CONVERT A CHARACTER TO LOWER CASE
  2582. X            <chr>       the character
  2583. X            returns     the lower case character
  2584. X
  2585. X        (digit-char <n>)  CONVERT A DIGIT WEIGHT TO A DIGIT
  2586. X            <n>         the digit weight (integer)
  2587. X            returns     the digit character or nil
  2588. X
  2589. X        (char-int <chr>) CONVERT A CHARACTER TO AN INTEGER
  2590. X            <chr>       the character
  2591. X            returns     the ASCII character code
  2592. X
  2593. X        (int-char <int>) CONVERT AN INTEGER TO A CHARACTER
  2594. X            <int>       the ASCII character code
  2595. X            returns     the character with that code
  2596. X
  2597. X
  2598. X
  2599. X
  2600. X
  2601. X
  2602. X
  2603. X
  2604. X
  2605. X
  2606. X
  2607. X
  2608. X
  2609. X        XLISP                 CHARACTER FUNCTIONS                Page 40
  2610. X
  2611. X
  2612. X        (char< <chr1> <chr2>...)
  2613. X        (char<= <chr1> <chr2>...)
  2614. X        (char= <chr1> <chr2>...)
  2615. X        (char/= <chr1> <chr2>...)
  2616. X        (char>= <chr1> <chr2>...)
  2617. X        (char> <chr1> <chr2>...)
  2618. X            <chr1>      the first character to compare
  2619. X            <chr2>      the second character(s) to compare
  2620. X            returns     t if predicate is true, nil otherwise
  2621. X          Note: case is significant with these comparison functions.
  2622. X
  2623. X        (char-lessp <chr1> <chr2>...)
  2624. X        (char-not-greaterp <chr1> <chr2>...)
  2625. X        (char-equalp <chr1> <chr2>...)
  2626. X        (char-not-equalp <chr1> <chr2>...)
  2627. X        (char-not-lessp <chr1> <chr2>...)
  2628. X        (char-greaterp <chr1> <chr2>...)
  2629. X            <chr1>      the first string to compare
  2630. X            <chr2>      the second string(s) to compare
  2631. X            returns     t if predicate is true, nil otherwise
  2632. X          Note: case is not significant with these comparison functions.
  2633. X
  2634. X
  2635. X
  2636. X
  2637. X
  2638. X
  2639. X
  2640. X
  2641. X
  2642. X
  2643. X
  2644. X
  2645. X
  2646. X
  2647. X
  2648. X
  2649. X
  2650. X
  2651. X
  2652. X
  2653. X
  2654. X
  2655. X
  2656. X
  2657. X
  2658. X
  2659. X
  2660. X
  2661. X
  2662. X
  2663. X
  2664. X
  2665. X
  2666. X
  2667. X
  2668. X
  2669. X
  2670. X
  2671. X
  2672. X
  2673. X
  2674. X
  2675. X        XLISP                INPUT/OUTPUT FUNCTIONS              Page 41
  2676. X
  2677. X
  2678. X        INPUT/OUTPUT FUNCTIONS
  2679. X
  2680. X        (read [<stream> [<eof> [<rflag>]]])  READ AN EXPRESSION
  2681. X            <stream>    the input stream (default is standard input)
  2682. X            <eof>       the value to return on end of file (default is nil)
  2683. X            <rflag>     recursive read flag (default is nil)
  2684. X            returns     the expression read
  2685. X
  2686. X        (print <expr> [<stream>])  PRINT AN EXPRESSION ON A NEW LINE
  2687. X            <expr>      the expression to be printed
  2688. X            <stream>    the output stream (default is standard output)
  2689. X            returns     the expression
  2690. X
  2691. X        (prin1 <expr> [<stream>])  PRINT AN EXPRESSION
  2692. X            <expr>      the expression to be printed
  2693. X            <stream>    the output stream (default is standard output)
  2694. X            returns     the expression
  2695. X
  2696. X        (princ <expr> [<stream>])  PRINT AN EXPRESSION WITHOUT QUOTING
  2697. X            <expr>      the expressions to be printed
  2698. X            <stream>    the output stream (default is standard output)
  2699. X            returns     the expression
  2700. X
  2701. X        (pprint <expr> [<stream>])  PRETTY PRINT AN EXPRESSION
  2702. X            <expr>      the expressions to be printed
  2703. X            <stream>    the output stream (default is standard output)
  2704. X            returns     the expression
  2705. X
  2706. X        (terpri [<stream>])  TERMINATE THE CURRENT PRINT LINE
  2707. X            <stream>    the output stream (default is standard output)
  2708. X            returns     nil
  2709. X
  2710. X        (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  2711. X            <expr>      the expression
  2712. X            returns     the length
  2713. X
  2714. X        (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  2715. X            <expr>      the expression
  2716. X            returns     the length
  2717. X
  2718. X
  2719. X
  2720. X
  2721. X
  2722. X
  2723. X
  2724. X
  2725. X
  2726. X
  2727. X
  2728. X
  2729. X
  2730. X
  2731. X
  2732. X
  2733. X
  2734. X
  2735. X
  2736. X
  2737. X
  2738. X
  2739. X
  2740. X
  2741. X        XLISP                 THE FORMAT FUNCTION                Page 42
  2742. X
  2743. X
  2744. X        THE FORMAT FUNCTION
  2745. X
  2746. X        (format <stream> <fmt> <arg>...)  DO FORMATTED OUTPUT
  2747. X            <stream>    the output stream
  2748. X            <fmt>       the format string
  2749. X            <arg>       the format arguments
  2750. X            returns     output string if <stream> is nil, nil otherwise
  2751. X
  2752. X        The format string can contain characters that should be copied
  2753. X        directly to the output and formatting directives.  The
  2754. X        formatting directives are:
  2755. X
  2756. X            ~A          print next argument using princ
  2757. X            ~S          print next argument using prin1
  2758. X            ~%          start a new line
  2759. X            ~~          print a tilde character
  2760. X
  2761. X
  2762. X
  2763. X
  2764. X
  2765. X
  2766. X
  2767. X
  2768. X
  2769. X
  2770. X
  2771. X
  2772. X
  2773. X
  2774. X
  2775. X
  2776. X
  2777. X
  2778. X
  2779. X
  2780. X
  2781. X
  2782. X
  2783. X
  2784. X
  2785. X
  2786. X
  2787. X
  2788. X
  2789. X
  2790. X
  2791. X
  2792. X
  2793. X
  2794. X
  2795. X
  2796. X
  2797. X
  2798. X
  2799. X
  2800. X
  2801. X
  2802. X
  2803. X
  2804. X
  2805. X
  2806. X
  2807. X        XLISP                  FILE I/O FUNCTIONS                Page 43
  2808. X
  2809. X
  2810. X        FILE I/O FUNCTIONS
  2811. X
  2812. X        (open <fname> &key :direction)  OPEN A FILE STREAM
  2813. X            <fname>     the file name string or symbol
  2814. X            :direction  :input or :output (default is :input)
  2815. X            returns     a stream
  2816. X
  2817. X        (close <stream>)  CLOSE A FILE STREAM
  2818. X            <stream>    the stream
  2819. X            returns     nil
  2820. X
  2821. X        (read-char [<stream>])  READ A CHARACTER FROM A STREAM
  2822. X            <stream>    the input stream (default is standard input)
  2823. X            returns     the character
  2824. X
  2825. X        (peek-char [<flag> [<stream>]])  PEEK AT THE NEXT CHARACTER
  2826. X            <flag>      flag for skipping white space (default is nil)
  2827. X            <stream>    the input stream (default is standard input)
  2828. X            returns     the character (integer)
  2829. X
  2830. X        (write-char <ch> [<stream>])  WRITE A CHARACTER TO A STREAM
  2831. X            <ch>        the character to write
  2832. X            <stream>    the output stream (default is standard output)
  2833. X            returns     the character
  2834. X
  2835. X        (read-line [<stream>])  READ A LINE FROM A STREAM
  2836. X            <stream>    the input stream (default is standard input)
  2837. X            returns     the string
  2838. X
  2839. X        (read-byte [<stream>])  READ A BYTE FROM A STREAM
  2840. X            <stream>    the input stream (default is standard input)
  2841. X            returns     the byte (integer)
  2842. X
  2843. X        (write-byte <byte> [<stream>])  WRITE A BYTE TO A STREAM
  2844. X            <byte>      the byte to write (integer)
  2845. X            <stream>    the output stream (default is standard output)
  2846. X            returns     the byte (integer)
  2847. X
  2848. X
  2849. X
  2850. X
  2851. X
  2852. X
  2853. X
  2854. X
  2855. X
  2856. X
  2857. X
  2858. X
  2859. X
  2860. X
  2861. X
  2862. X
  2863. X
  2864. X
  2865. X
  2866. X
  2867. X
  2868. X
  2869. X
  2870. X
  2871. X
  2872. X
  2873. X        XLISP               STRING STREAM FUNCTIONS              Page 44
  2874. X
  2875. X
  2876. X        STRING STREAM FUNCTIONS
  2877. X
  2878. X        These functions operate on unnamed streams.  An unnamed output
  2879. X        stream collects characters sent to it when it is used as the
  2880. X        destination of any output function.  The functions 'get-output-
  2881. X        stream-string' and string or a list of characters.
  2882. X
  2883. X        An unnamed input stream is setup with the 'make-string-input-
  2884. X        stream' function and returns each character of the string when
  2885. X        it is used as the source of any input function.
  2886. X
  2887. X        (make-string-input-stream <str> [<start> [<end>]])
  2888. X            <str>       the string
  2889. X            <start>     the starting offset
  2890. X            <end>       the ending offset + 1
  2891. X            returns     an unnamed stream that reads from the string
  2892. X
  2893. X        (make-string-output-stream)
  2894. X            returns     an unnamed output stream
  2895. X
  2896. X        (get-output-stream-string <stream>)
  2897. X            <stream>    the output stream
  2898. X            returns     the output so far as a string
  2899. X          Note:  the output stream is emptied by this function
  2900. X
  2901. X        (get-output-stream-list <stream>)
  2902. X            <stream>    the output stream
  2903. X            returns     the output so far as a list
  2904. X          Note:  the output stream is emptied by this function
  2905. X
  2906. X
  2907. X
  2908. X
  2909. X
  2910. X
  2911. X
  2912. X
  2913. X
  2914. X
  2915. X
  2916. X
  2917. X
  2918. X
  2919. X
  2920. X
  2921. X
  2922. X
  2923. X
  2924. X
  2925. X
  2926. X
  2927. X
  2928. X
  2929. X
  2930. X
  2931. X
  2932. X
  2933. X
  2934. X
  2935. X
  2936. X
  2937. X
  2938. X
  2939. X        XLISP                      STRUCTURES                    Page 45
  2940. X
  2941. X
  2942. X        STRUCTURES
  2943. X
  2944. X        XLISP provides a subset of the Common Lisp structure definition
  2945. X        facility.  No options or slot options are allowed, but slots can
  2946. X        have default initialization expressions.
  2947. X
  2948. X        (defstruct name <slot-desc>...)
  2949. X        or
  2950. X        (defstruct (name <option>...) <slot-desc>...)
  2951. X            <name>      the structure name symbol
  2952. X            <option>    option description
  2953. X            <slot-desc> slot descriptions
  2954. X            returns     the structure name
  2955. X
  2956. X        The recognized options are:
  2957. X
  2958. X                (:conc-name name)
  2959. X                (:include name [<slot-desc>...])
  2960. X
  2961. X        Note that if :CONC-NAME appears, it should be before :INCLUDE.
  2962. X
  2963. X        Each slot description takes the form:
  2964. X
  2965. X                <name>
  2966. X        or
  2967. X                (<name> <defexpr>)
  2968. X
  2969. X        If the default initialization expression is not specified, the
  2970. X        slot will be initialized to NIL if no keyword argument is passed
  2971. X        to the creation function.
  2972. X
  2973. X        DEFSTRUCT causes access functions to be created for each of the
  2974. X        slots and also arranges that SETF will work with those access
  2975. X        functions.  The access function names are constructed by taking
  2976. X        the structure name, appending a '-' and then appending the slot
  2977. X        name.  This can be overridden by using the :CONC-NAME option.
  2978. X
  2979. X        DEFSTRUCT also makes a creation function called MAKE-
  2980. X        <structname>, a copy function called COPY-<structname> and a
  2981. X        predicate function called <structname>-P.  The creation function
  2982. X        takes keyword arguments for each of the slots.
  2983. X
  2984. X        For instance:
  2985. X
  2986. X                (defstruct foo bar (gag 2))
  2987. X
  2988. X        creates the following functions:
  2989. X
  2990. X                (foo-bar <expr>)
  2991. X                (setf (foo-bar <expr>) <value>)
  2992. X                (foo-gag <expr>)
  2993. X                (setf (foo-gag <expr>) <value>)
  2994. X                (make-foo &key :bar :gag)
  2995. X                (copy-foo <expr>)
  2996. X
  2997. X
  2998. X
  2999. X
  3000. X
  3001. X
  3002. X
  3003. X
  3004. X
  3005. X        XLISP                      STRUCTURES                    Page 46
  3006. X
  3007. X
  3008. X                (foo-p <expr>)
  3009. X
  3010. X
  3011. X
  3012. X
  3013. X
  3014. X
  3015. X
  3016. X
  3017. X
  3018. X
  3019. X
  3020. X
  3021. X
  3022. X
  3023. X
  3024. X
  3025. X
  3026. X
  3027. X
  3028. X
  3029. X
  3030. X
  3031. X
  3032. X
  3033. X
  3034. X
  3035. X
  3036. X
  3037. X
  3038. X
  3039. X
  3040. X
  3041. X
  3042. X
  3043. X
  3044. X
  3045. X
  3046. X
  3047. X
  3048. X
  3049. X
  3050. X
  3051. X
  3052. X
  3053. X
  3054. X
  3055. X
  3056. X
  3057. X
  3058. X
  3059. X
  3060. X
  3061. X
  3062. X
  3063. X
  3064. X
  3065. X
  3066. X
  3067. X
  3068. X
  3069. X
  3070. X
  3071. X        XLISP                   SYSTEM FUNCTIONS                 Page 47
  3072. X
  3073. X
  3074. X        SYSTEM FUNCTIONS
  3075. X
  3076. X        (load <fname> &key :verbose :print)  LOAD A SOURCE FILE
  3077. X            <fname>     the filename string or symbol
  3078. X            :verbose    the verbose flag (default is t)
  3079. X            :print      the print flag (default is nil)
  3080. X            returns     the filename
  3081. X
  3082. X        (save <fname>) SAVE WORKSPACE TO A FILE
  3083. X            <fname>     the filename string or symbol
  3084. X            returns     t if workspace was written, nil otherwise
  3085. X
  3086. X        (restore <fname>) RESTORE WORKSPACE FROM A FILE
  3087. X            <fname>     the filename string or symbol
  3088. X            returns     nil on failure, otherwise never returns
  3089. X
  3090. X        (dribble [<fname>])  CREATE A FILE WITH A TRANSCRIPT OF A SESSION
  3091. X            <fname>     file name string or symbol
  3092. X                        (if missing, close current transcript)
  3093. X            returns     t if the transcript is opened, nil if it is closed
  3094. X
  3095. X        (gc)  FORCE GARBAGE COLLECTION
  3096. X            returns     nil
  3097. X
  3098. X        (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  3099. X            <num>       the number of segments to add
  3100. X            returns     the number of segments added
  3101. X
  3102. X        (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  3103. X            <num>       the number of nodes to allocate
  3104. X            returns     the old number of nodes to allocate
  3105. X
  3106. X        (room)  SHOW MEMORY ALLOCATION STATISTICS
  3107. X            returns     nil
  3108. X
  3109. X        (type-of <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  3110. X            <expr>      the expression to return the type of
  3111. X            returns     nil if the value is nil otherwise one of the symbols:
  3112. X                          SYMBOL          for symbols
  3113. X                          OBJECT          for objects
  3114. X                          CONS            for conses
  3115. X                          SUBR            for built-in functions
  3116. X                          FSUBR           for special forms
  3117. X                          CLOSURE         for defined functions
  3118. X                          STRING          for strings
  3119. X                          FIXNUM          for integers
  3120. X                          FLONUM          for floating point numbers
  3121. X                          CHARACTER       for characters
  3122. X                          FILE-STREAM     for file pointers
  3123. X                          UNNAMED-STREAM  for unnamed streams
  3124. X                          ARRAY           for arrays
  3125. X
  3126. X
  3127. X
  3128. X
  3129. X
  3130. X
  3131. X
  3132. X
  3133. X
  3134. X
  3135. X
  3136. X
  3137. X        XLISP                   SYSTEM FUNCTIONS                 Page 48
  3138. X
  3139. X
  3140. X        (peek <addrs>)  PEEK AT A LOCATION IN MEMORY
  3141. X            <addrs>     the address to peek at (integer)
  3142. X            returns     the value at the specified address (integer)
  3143. X
  3144. X        (poke <addrs> <value>)  POKE A VALUE INTO MEMORY
  3145. X            <addrs>     the address to poke (integer)
  3146. X            <value>     the value to poke into the address (integer)
  3147. X            returns     the value
  3148. X
  3149. X        (address-of <expr>)  GET THE ADDRESS OF AN XLISP NODE
  3150. X            <expr>      the node
  3151. X            returns     the address of the node (integer)
  3152. X
  3153. X        (exit)  EXIT XLISP
  3154. X            returns     never returns
  3155. X
  3156. X
  3157. X
  3158. X
  3159. X
  3160. X
  3161. X
  3162. X
  3163. X
  3164. X
  3165. X
  3166. X
  3167. X
  3168. X
  3169. X
  3170. X
  3171. X
  3172. X
  3173. X
  3174. X
  3175. X
  3176. X
  3177. X
  3178. X
  3179. X
  3180. X
  3181. X
  3182. X
  3183. X
  3184. X
  3185. X
  3186. X
  3187. X
  3188. X
  3189. X
  3190. X
  3191. X
  3192. X
  3193. X
  3194. X
  3195. X
  3196. X
  3197. X
  3198. X
  3199. X
  3200. X
  3201. X
  3202. X
  3203. X        XLISP                       EXAMPLES                     Page 49
  3204. X
  3205. X
  3206. X        FILE I/O FUNCTIONS
  3207. X
  3208. X        Input from a File
  3209. X
  3210. X        To open a file for input, use the OPEN function with the keyword
  3211. X        argument :DIRECTION set to :INPUT.  To open a file for output,
  3212. X        use the OPEN function with the keyword argument :DIRECTION set
  3213. X        to :OUTPUT.  The OPEN function takes a single required argument
  3214. X        which is the name of the file to be opened.  This name can be in
  3215. X        the form of a string or a symbol.  The OPEN function returns an
  3216. X        object of type FILE-STREAM if it succeeds in opening the
  3217. X        specified file.  It returns the value NIL if it fails.  In order
  3218. X        to manipulate the file, it is necessary to save the value
  3219. X        returned by the OPEN function.  This is usually done by
  3220. X        assigning it to a variable with the SETQ special form or by
  3221. X        binding it using LET or LET*.  Here is an example:
  3222. X
  3223. X            (setq fp (open "init.lsp" :direction :input))
  3224. X
  3225. X        Evaluating this expression will result in the file "init.lsp"
  3226. X        being opened.  The file object that will be returned by the OPEN
  3227. X        function will be assigned to the variable "fp".
  3228. X
  3229. X        It is now possible to use the file for input.  To read an
  3230. X        expression from the file, just supply the value of the "fp"
  3231. X        variable as the optional "stream" argument to READ.
  3232. X
  3233. X            (read fp)
  3234. X
  3235. X        Evaluating this expression will result in reading the first
  3236. X        expression from the file "init.lsp".  The expression will be
  3237. X        returned as the result of the READ function.  More expressions
  3238. X        can be read from the file using further calls to the READ
  3239. X        function.  When there are no more expressions to read, the READ
  3240. X        function will return NIL (or whatever value was supplied as the
  3241. X        second argument to READ).
  3242. X
  3243. X        Once you are done reading from the file, you should close it.
  3244. X        To close the file, use the following expression:
  3245. X
  3246. X            (close fp)
  3247. X
  3248. X        Evaluating this expression will cause the file to be closed.
  3249. X
  3250. X
  3251. X
  3252. X
  3253. X
  3254. X
  3255. X
  3256. X
  3257. X
  3258. X
  3259. X
  3260. X
  3261. X
  3262. X
  3263. X
  3264. X
  3265. X
  3266. X
  3267. X
  3268. X
  3269. X        XLISP                       EXAMPLES                     Page 50
  3270. X
  3271. X
  3272. X        Output to a File
  3273. X
  3274. X        Writing to a file is pretty much the same as reading from one.
  3275. X        You need to open the file first.  This time you should use the
  3276. X        OPEN function to indicate that you will do output to the file.
  3277. X        For example:
  3278. X
  3279. X            (setq fp (open "test.dat" :direction :output))
  3280. X
  3281. X        Evaluating this expression will open the file "test.dat" for
  3282. X        output.  If the file already exists, its current contents will
  3283. X        be discarded.  If it doesn't already exist, it will be created.
  3284. X        In any case, a FILE-STREAM object will be returned by the OPEN
  3285. X        function.  This file object will be assigned to the "fp"
  3286. X        variable.
  3287. X
  3288. X        It is now possible to write to this file by supplying the value
  3289. X        of the "fp" variable as the optional "stream" parameter in the
  3290. X        PRINT function.
  3291. X
  3292. X            (print "Hello there" fp)
  3293. X
  3294. X        Evaluating this expression will result in the string "Hello
  3295. X        there" being written to the file "test.dat".  More data can be
  3296. X        written to the file using the same technique.
  3297. X
  3298. X        Once you are done writing to the file, you should close it.
  3299. X        Closing an output file is just like closing an input file.
  3300. X
  3301. X            (close fp)
  3302. X
  3303. X        Evaluating this expression will close the output file and make
  3304. X        it permanent.
  3305. X
  3306. X
  3307. X
  3308. X
  3309. X
  3310. X
  3311. X
  3312. X
  3313. X
  3314. X
  3315. X
  3316. X
  3317. X
  3318. X
  3319. X
  3320. X
  3321. X
  3322. X
  3323. X
  3324. X
  3325. X
  3326. X
  3327. X
  3328. X
  3329. X
  3330. X
  3331. X
  3332. X
  3333. X
  3334. X
  3335. X        XLISP                       EXAMPLES                     Page 51
  3336. X
  3337. X
  3338. X        A Slightly More Complicated File Example
  3339. X
  3340. X        This example shows how to open a file, read each Lisp expression
  3341. X        from the file and print it.  It demonstrates the use of files
  3342. X        and the use of the optional "stream" argument to the READ
  3343. X        function.
  3344. X
  3345. X            (do* ((fp (open "test.dat" :direction :input))
  3346. X                  (ex (read fp) (read fp)))
  3347. X                 ((null ex) nil)
  3348. X              (print ex))
  3349. X
  3350. X
  3351. X
  3352. X
  3353. X
  3354. X
  3355. X
  3356. X
  3357. X
  3358. X
  3359. X
  3360. X
  3361. X
  3362. X
  3363. X
  3364. X
  3365. X
  3366. X
  3367. X
  3368. X
  3369. X
  3370. X
  3371. X
  3372. X
  3373. X
  3374. X
  3375. X
  3376. X
  3377. X
  3378. X
  3379. X
  3380. X
  3381. X
  3382. X
  3383. X
  3384. X
  3385. X
  3386. X
  3387. X
  3388. X
  3389. X
  3390. X
  3391. X
  3392. X
  3393. X
  3394. X
  3395. X
  3396. X
  3397. X
  3398. X
  3399. X        XLISP        UN*X-SPECIFIC FUNCTIONS (FOR WINTERP)       Page 52
  3400. X
  3401. X
  3402. X    The following functions were added to XLISP by Niels Mayer
  3403. X    for use with WINTERP. These functions are UN*X-specific:
  3404. X
  3405. X    POPEN - start a process and open a pipe as a read/write stream
  3406. X        (popen <shell-command> :direction <direction>)
  3407. X            <shell-cmd>    is a string which is sent to shell
  3408. X                /bin/sh and is executed as command.
  3409. X            <direction>    a keyword symbol, :input means a stream
  3410. X                is created that reads from stdout of
  3411. X                <shell-cmd>; :output means a stream
  3412. X                is created that writes to stdin of 
  3413. X                <shell-cmd>. (:input is the default.)
  3414. X            returns    a stream, or NIL if the pipe or /bin/sh 
  3415. X                process couldn't be created.
  3416. X
  3417. X    PCLOSE -- close a pipe stream as opened by POPEN.
  3418. X        (pclose <stream>)
  3419. X            <stream>    a stream object created by POPEN
  3420. X            returns    T if the command executed successfully, else
  3421. X                returns the integer exit status of
  3422. X                <shell-cmd>.
  3423. X
  3424. X    SYSTEM - run a process, sending output (if any) to stdout/stderr
  3425. X        (system <shell-cmd>)
  3426. X            <shell-cmd> is a string which is sent to shell
  3427. X                /bin/sh and is executed as command.
  3428. X            returns    T if the command executed successfully,
  3429. X                else returns the integer exit status of
  3430. X                <shell-cmd>.
  3431. X
  3432. X
  3433. X
  3434. X
  3435. X
  3436. X
  3437. X
  3438. X
  3439. X
  3440. X
  3441. X
  3442. X
  3443. X
  3444. X
  3445. X
  3446. X
  3447. X
  3448. X
  3449. X
  3450. X
  3451. X
  3452. X
  3453. X
  3454. X
  3455. X
  3456. X
  3457. X
  3458. X
  3459. X
  3460. X
  3461. X
  3462. X
  3463. X
  3464. X
  3465. X        XLISP        UN*X-SPECIFIC FUNCTIONS (FOR WINTERP)       Page 53
  3466. X
  3467. X
  3468. X    FSCANF-FIXNUM - read a fixnum value from a stream using fscanf(3x).
  3469. X        (fscanf-fixnum <stream> <format>)
  3470. X            <stream>    a stream object created via OPEN or POPEN.
  3471. X                Will give an error for "unnamed streams".
  3472. X            <format>    a format string containing a single
  3473. X                conversion directive that will result in
  3474. X                an integer valued conversion %d, %u, %o,
  3475. X                %x, %ld, %lu, %lo and %lx style conversions 
  3476. X                are acceptable for this routine. See the
  3477. X                manual page for fscanf(3x) for details.
  3478. X            returns    an integer if fscanf(3x) reports that
  3479. X                the conversion specified by <format> 
  3480. X                succeeded. Returns NIL if the conversion
  3481. X                wasn't successful, or if EOF was reached.
  3482. X
  3483. X        WARNING: specifying a <format> that will result in the
  3484. X        conversion of a result larger than sizeof(long) will result in
  3485. X        corrupted memory and core dumps. 
  3486. X
  3487. X    FSCANF-STRING - read a string value from a stream using fscanf(3x).
  3488. X        (fscanf-string <stream> <format>)
  3489. X            <stream>    a stream object created via OPEN or POPEN.
  3490. X                Will give an error for "unnamed streams".
  3491. X            <format>    a format string containing a single
  3492. X                conversion directive that will result in
  3493. X                a string valued conversion. %s, %c, and
  3494. X                %[...] style conversions are acceptable for
  3495. X                this routine. See the manual page for
  3496. X                fscanf(3x) for details.
  3497. X            returns    a string if fscanf(3x) reports that
  3498. X                the conversion specified by <format> 
  3499. X                succeeded. Returns NIL if the conversion
  3500. X                wasn't successful, or if EOF was reached.
  3501. X
  3502. X        WARNING: specifying a <scanf-format> that will result in the
  3503. X        conversion of a result larger than 1024 characters will result
  3504. X        in corrupted memory and core dumps.
  3505. X
  3506. X    FSCANF-FLONUM - read a float from a stream using fscanf(3x).
  3507. X        (fscanf-flonum <stream> <format>)
  3508. X            <stream>    a stream object created via OPEN or POPEN.
  3509. X                Will give an error for "unnamed streams".
  3510. X            <format>    a format string containing a single
  3511. X                conversion directive that will result in
  3512. X                a FLONUM valued conversion. %e %f or %g
  3513. X                are valid conversion specifiers for this
  3514. X                routine. See the manual page for fscanf(3x)
  3515. X                for details.
  3516. X            returns    a float if fscanf(3x) reports that
  3517. X                the conversion specified by <format> 
  3518. X                succeeded. Returns NIL if the conversion
  3519. X                wasn't successful, or if EOF was reached.
  3520. X
  3521. X        WARNING: specifying a <scanf-format> that will result in the
  3522. X        conversion of a result larger than sizeof(float) will result in
  3523. X        corrupted memory and core dumps.
  3524. END_OF_FILE
  3525. if test 88634 -ne `wc -c <'docs/xlisp.doc'`; then
  3526.     echo shar: \"'docs/xlisp.doc'\" unpacked with wrong size!
  3527. fi
  3528. # end of 'docs/xlisp.doc'
  3529. fi
  3530. echo shar: End of archive 16 \(of 16\).
  3531. cp /dev/null ark16isdone
  3532. MISSING=""
  3533. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  3534.     if test ! -f ark${I}isdone ; then
  3535.     MISSING="${MISSING} ${I}"
  3536.     fi
  3537. done
  3538. if test "${MISSING}" = "" ; then
  3539.     echo You have unpacked all 16 archives.
  3540.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3541. else
  3542.     echo You still need to unpack the following archives:
  3543.     echo "        " ${MISSING}
  3544. fi
  3545. ##  End of shell archive.
  3546. exit 0
  3547.